x97wehner Posted November 9, 2023 Posted November 9, 2023 Google product feeds ask for a sale price if it's available. I'm trying to figure out how to set this up within my XML feed with @datakick module and am stuck. Today, the feed just shows the <g:price> node as the actual final price, whether discounted or not. What should happen is that in the XML feed: <g:price> Should always equal the non-discounted price. (The base price from the product, combination, or the specific price being used) <g:sale_price> Should always equal the discounted price if the product or combination is discounted. Comes from the product, combination, or specific price being used. Otherwise would be null if not discounted. Has anyone figured out if and how to make the @datakick module make this setup work? If so, what formulas are you using? Thanks for the help
datakick Posted November 10, 2023 Posted November 10, 2023 For <g:price> use base product base price + combination impact. Datakick expression for this is (if your combination table has combination alias) combination.productBasePrice + combination.priceImpact for <g:sale_price> use function productPrice(productId, combinationId). Expression is: productPrice(combination.productId, combination.id, false) Function productPrice calculates final price for given target audience (customer group, currency, country), and it does take into account all discounts and specific prices. In my test, I've created shop-wide specific price rule that gives 10% discount, result is this: Here is attached template in json format, you can import it to your datakick installation for testing test-prices.json
x97wehner Posted November 10, 2023 Author Posted November 10, 2023 (edited) 6 hours ago, datakick said: For <g:price> use base product base price + combination impact. Datakick expression for this is (if your combination table has combination alias) combination.productBasePrice + combination.priceImpact for <g:sale_price> use function productPrice(productId, combinationId). Expression is: productPrice(combination.productId, combination.id, false) Function productPrice calculates final price for given target audience (customer group, currency, country), and it does take into account all discounts and specific prices. In my test, I've created shop-wide specific price rule that gives 10% discount, result is this: Here is attached template in json format, you can import it to your datakick installation for testing test-prices.json 1.62 kB · 0 downloads This helps me half-way, so thank you very much. For my shop's default currency when there is a sale, it populates perfectly. There are still a couple other situations I'm still struggling with here: - When there is no sale, it's filling in the regular price into the sale_price node. It should be null if there is no sale. - It doesn't bring in the base price from the specific price into the price node. Only the base price from the product/combination in default shop currency populates. We have country and currency specific pricing in so the base price from the specific price needs to show in the price node. I'm sure these can be handled as well, I just can't figure it out myself. Do you know how @datakick? Edited November 10, 2023 by x97wehner
datakick Posted November 11, 2023 Posted November 11, 2023 Hi, the first thing is easy. You can use if(<cond>, <truth>, <false>) expression to only emit content of sale_price when it's different to base price. Something like this if(productPrice(combination.productId, combination.id, false) != (combination.productBasePrice + combination.priceImpact), toString(productPrice(combination.productId, combination.id, false)), '') This will display empty string if the both prices are the same. You can then check "Omit empty" checkbox on <g:sale_price> to hide it if empty. The second problem is not possible to solve with datakick module, I'm afraid. There is no function that would calculate base price for specific price for given country.
x97wehner Posted November 11, 2023 Author Posted November 11, 2023 5 hours ago, datakick said: Hi, the first thing is easy. You can use if(<cond>, <truth>, <false>) expression to only emit content of sale_price when it's different to base price. Something like this if(productPrice(combination.productId, combination.id, false) != (combination.productBasePrice + combination.priceImpact), toString(productPrice(combination.productId, combination.id, false)), '') This will display empty string if the both prices are the same. You can then check "Omit empty" checkbox on <g:sale_price> to hide it if empty. The second problem is not possible to solve with datakick module, I'm afraid. There is no function that would calculate base price for specific price for given country. That's unfortunate, but thanks again for the help with the first part.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now