5

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!

1 Answer 1

5

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.

1
  • 1
    Great to see this problem addressed as I haven't seen it on here before - but you could revise the answer to give more generic information that would be valuable for future visitors.
    – philwinkle
    Commented Jan 16, 2014 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.