所以我们将“最近查看” block 放入我们的产品 View 中。一开始一切似乎都很好,但我现在看到与 null 布局有关的奇怪错误。如果我关闭缓存,它工作正常,但启用整页缓存时,它在调用 $this->getColumnCount(); 时失败。在模板中。
我为启用最近在产品页面上查看的内容所做的是:
在 catalog_product_view 的内容 block 内的 catalog.xml 中:
<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>
在模板文件中:catalog/product/view.phtml:
<?php echo $this->getChildHtml('recently_viewed') ?>
第一次加载一切正常,但如果我点击另一个产品 View ,然后重新加载页面,它就会出错。我将错误追溯到类:Mage_Page_Helper_Layout。
函数 getCurrentPageLayout(),有一行:
$this->getLayout()->getBlock('root')
和 $this->getLayout 返回 null,导致 getBlock 调用抛出异常。
如果我禁用缓存,则不会出现任何错误,并且一切正常。
最佳答案
你运行的是哪个版本?据我所知,Magento Enterprise 1.9 在全页缓存方面存在严重问题。抱歉,我不能提供更多帮助。
关于php - Magento : Moving "Recently Viewed" to product page creates weird caching error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3961991/