Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ItemZone on product detail is not set correctly when chaning products via related/upsell products list #9562

Closed
juhanix opened this issue May 9, 2017 · 9 comments
Labels
bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@juhanix
Copy link

juhanix commented May 9, 2017

Preconditions

  1. Magento 2.1.5
  2. PHP7

Steps to reproduce

  1. change file vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml
    1.1. add echo $block->getZone(); on line 25 (or some other line, as you like)
  2. having Product A with Product B listed/marked as related or upsell.
    2.1. Product B also has Product A listed/marked as related or upsell product
  3. visiting Product A detail page
    3.1. main product: product A item_zone = "item_view"
    3.2. upsell/related product: product B item_zone = "item_list"
    3.3. everything is fine, this is how it should be
  4. visiting Product B detail page
    4.1. main product: product B item_zone = "item_list"
    4.2. upsell/related product: product A item_zone = "item_view"
    4.3. this is not how it should be
  5. clearing cache and now the other way around: visiting Product B detail page
    5.1. main product: product B item_zone = "item_view"
    5.2. upsell/related product: product A item_zone = "item_list"
    5.3. everything is fine, this is how it should be
    5.4. visiting Product A detail page and everything is wrong again

Expected result

  1. item_zone from the current product should always be "item_view" so the schema.org meta information for the price is set correctly

Actual result

  1. Already described in "steps to reproduce" section

UPDATE

so I checked if currently registered ProductID is the same productID as file vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml outouts in line 14
$this->_coreRegistry->registry('current_product'); gives me always the productID from the first product page I visit.
so I added following to vendor/magento/module-catalog/Pricing/Render/FinalPriceBox.php
public function getCacheLifetime() { return null; }
seems to work fine after this

@hostep
Copy link
Contributor

hostep commented Jun 2, 2017

Confirmed, we experience the same problem and this causes the wrong price to be displayed in Google ads because wrong data is being stored in the cache and this causes the price of one of the related products to be displayed in the google ads instead of the actual product price.

I'll debug a little bit further and see if there is a better solution then turning of the caching of the final price box.

@hostep
Copy link
Contributor

hostep commented Jun 2, 2017

This seems to fix it, not exactly sure if this is the correct approach though:

diff --git a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
index bab93e08f27..659c0129430 100644
--- a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
+++ b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
@@ -198,6 +198,7 @@ class FinalPriceBox extends BasePriceBox
         $cacheKeys = parent::getCacheKeyInfo();
         $cacheKeys['display_minimal_price'] = $this->getDisplayMinimalPrice();
         $cacheKeys['is_product_list'] = $this->isProductList();
+        $cacheKeys['zone_type'] = $this->getZone();
         return $cacheKeys;
     }

Tested on Magento 2.1.6

@hostep
Copy link
Contributor

hostep commented Jun 3, 2017

Ok, I dug in a bit further and discovered this bug is already fixed on the develop branch.

I then tried to figure out in what commit it was fixed, which took me a couple of hours, and found out it was fixed by a commit which fixes another issue, around currencies on product prices.
Commit: a9510d3
Other issue this commit fixes: #6746

So it can indeed be fixed by setting the cache lifetime to null. (not sure if this is the correct solution though, but since it exists on the develop branch, let's assume it is the correct solution)

If I apply the above commit on Magento 2.1.7, it looks like it fixes the issue.

I'll look into backporting MAGETWO-59089 to the 2.1-develop branch, to try to include this fix in one of the next minor 2.1.x releases.

@Stas94
Copy link

Stas94 commented Jun 29, 2017

@juhanix Created internal issue MAGETWO-69655 to investigate and track this issue.

@hostep
Copy link
Contributor

hostep commented Jun 29, 2017

@Stas94: This has already been fixed: #9841
Unless I'm missing something here?

@magento-team magento-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Jul 31, 2017
@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-69665

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team
Copy link
Contributor

Hi @juhanix
This issue is already fixed in 2.1.8 and onwards in the scope of the PR #9841
We are closing this ticket now, please reopen if problem persists.
Thank you

@harrigo
Copy link

harrigo commented Nov 11, 2019

Similar seems to be happening for me with grouped products. If I visit a grouped product the child products seem to be cached with the "item_list" zone causing issues with rendering of price on the child products when they are later visited on their specific product page. These then show "item_list" instead of "item_view". @hostep solution works for fixing the issue.

Have not started properly debugging on vanilla instance however.

@fm-cl
Copy link

fm-cl commented Aug 4, 2022

Thanks @hostep I was going crazy with this issue, 2 months looking for a solucion and I find this ticket!

Thank you very much, this happend to me on magneto 2.4.2-p2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

8 participants