Jump to content
thirty bees forum

Google product feed with Datakick module sale_price node question


x97wehner

Recommended Posts

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

Link to comment
Share on other sites

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:

image.png.98105499e2e18e1ede427e5dfdcdb692.png

Here is attached template in json format, you can import it to your datakick installation for testing

test-prices.json

Link to comment
Share on other sites

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:

image.png.98105499e2e18e1ede427e5dfdcdb692.png

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 by x97wehner
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...