views:

40

answers:

1

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.