Question

I am trying to figure out why a Magento Enterprise website is displaying the same item four times in the 'related item' section of the page.

CORRECT BEHAVIOR:
- After clearing caches, four different items are shown on the first page load (this is the correct behavior)

PROBLEM: - Additional page loads show not just the same four items, but the exact same item repeated four times (see screenshot)
- The item which is repeated is always the last item that was displayed in the original page load. In other words if there are a,b,c,d related items shown on the first page load after a cache fush, it is 'd' that will be repeated four times on future page loads. d,d,d,d

Same exact item repeated four times

BACKGROUND:
- Page uses a custom theme.
- This problem only takes place when full page caching is turned on.
- If the page is returned to the 'default' theme, the problem no longer takes place, even with full page caching turned on
- To recap: the problem only occurs with the custom theme and full page caching turned on
- Magento Enterprise ver. 1.13.0.0

The related products portion of the page is inserted with the following code:

<?php echo $this->getChildHtml('relatedProducts', false) ?>

I would be grateful for:
- A specific lead on what this issue may be
- Reliable ways to disable a specific cache related to this (in GUI? In code? In terminal?)
- Tests and steps I can take to narrow this down to code, db, or files.

Thank you in advance!

Was it helpful?

Solution

It turned out that we had created a local version of the default related.phtml file which was being used as the template for the related items block. In this code there is this line within a loop:

$itemBlock = $this->getChild('catalog.product.related.item')->setItem($_item)->setPosition($i);

Notice the $i variable near the end of the line.

This variable was not being incremented elsewhere in the code. I added $i = 0; before the loop and $i++; in the appropriate location within the loop. With the $i variable now incrementing, the repeating item problem has been resolved.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top