Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento : Moving "Recently Viewed" to product page creates weird caching error

So we have put the "recently viewed" block into our product view. Everything seems to look fine at first but I'm now seeing weird errors that have to do with null layouts. If i turn caching off it works fine, but with full page caching enabled it fails when calling $this->getColumnCount(); in the template.

What I have done to enable recently viewed on the product page was:

in catalog.xml inside the content block of catalog_product_view:

            <block type="reports/product_viewed" name="reports.product.viewed" as="recently_viewed" template="reports/product_viewed.phtml">
                <action method="setColumnCount"><columns>4</columns></action>
                <action method="setItemLimit"><type>recently_viewed</type><limit>4</limit></action>
            </block>

in the template file: catalog/product/view.phtml:

             <?php echo $this->getChildHtml('recently_viewed') ?>

everything loads fine the first time, but then if i click on another product view, then reload the page it errors out. I traced the error down to the class: Mage_Page_Helper_Layout.

the function getCurrentPageLayout(), has a line:

 $this->getLayout()->getBlock('root')

and $this->getLayout is returning null which causes the getBlock call to throw an exception.
if i disabled caching no errors come up and everything works fine.

like image 213
GeekPride Avatar asked Oct 13 '22 22:10

GeekPride


2 Answers

Which version are you running ? As far as I known, Magento Enterprise 1.9 have serious problems with Full Page Caching. Sorry I can't be more helpful.

like image 196
joksnet Avatar answered Oct 18 '22 09:10

joksnet


Have you just disabled caching in admin or actually deleted /var/cache? Magento might use old cached pages when you enable it again causing errors. There is button for flushing caches in cache management or you can do it manually.

like image 35
mikeful Avatar answered Oct 18 '22 10:10

mikeful