magmodules / magento2-channable

Channable Connect for Magento® 2
https://marketplace.magento.com/magmodules-magento2-channable.html
BSD 2-Clause "Simplified" License
28 stars 40 forks source link

Incorrect values for fields price and price_incl in feed for products with prices below 1 EUR #218

Closed s-renz closed 6 months ago

s-renz commented 7 months ago

Hi,

we recently got some notifications in Google Merchant Center for products that have prices differ in feed and on the page.

When we looked further into it we noticed that the common thing between these products is that they are all below 1 EUR. In this case the min_price and max_price correctly show the price without tax, however the fields "price" and "price_excl" already include the tax and as such the field "price_incl" will include the already taxed price including tax.

image

We traced the issue back to this line: https://github.com/magmodules/magento2-channable/blob/master/Helper/Product.php#L1006

Since the price is below 1 and we're talking floats here the else-branch is executed. So instead of using

$price = $product->getPrice();

this code is used:

$price = $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue();

Which returns the price already taxed, which is then put into processPrice and taxed again due to how the store configuration is set. As far as I can see there are two changes that work, however I don't know enough about Magento's price calculation to know if this is indeed a bug in Magento or in the Channable Extension, which is why I didn't want to do a pull request directly.

As far as I can see it, the AmountInterface always returns the price with all things included, unless you explicitly tell getValue() what to exclude:

$price = $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue('tax');
or
$price = $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue(['tax']);

The correct price is also returned when not using the Amount interface but instead get the Value directly:

$price = $product->getPriceInfo()->getPrice('regular_price')->getValue();

But again I am not qualified enough to know the difference or if that would break anything.

Could someone look into this please?

Frank-Magmodules commented 7 months ago

Hello @s-renz, thanks for bringing up this issue. We're currently looking into it, taking into account your detailed description and thorough review of the affected code lines and locations. I'll update you shortly, hopefully with a PR and/or a release where we've addressed this.

s-renz commented 6 months ago

Any news on this yet?

Frank-Magmodules commented 6 months ago

Hello @s-renz, Yes, sorry for the delay but we have good news! We've addressed this issue with a fix that will be included in the upcoming release later this month. Thank you for your patience, and I've also ensured that the appropriate label has been added to this issue.

s-renz commented 6 months ago

Hello @s-renz, Yes, sorry for the delay but we have good news! We've addressed this issue with a fix that will be included in the upcoming release later this month. Thank you for your patience, and I've also ensured that the appropriate label has been added to this issue.

Thanks! Looking forward to the new version

Frank-Magmodules commented 6 months ago

Hi There @s-renz ! Thank you again for opening this issue. I'm happy to share that we have covered this issue in our new release. I'm marking this issue as resolved for now. Please don't hesitate to reopen it if necessary. Thank you again for opening this issue!