因此我们将“最近查看过的”块放入我们的产品视图中。一开始看起来一切看起来都不错,但我现在看到与null布局有关的奇怪错误。如果我关闭缓存它工作正常,但启用完整页面缓存时,它调用$ this-> getColumnCount();在模板中。
我在产品页面上最近查看的内容是:
在catalog_product_view的内容块中的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') ?>
第一次一切都很好,但是如果我点击另一个产品视图,那么重新加载它出错的页面。我将错误追溯到了类:Mage_Page_Helper_Layout。
函数getCurrentPageLayout(),有一行:
$this->getLayout()->getBlock('root')
和$ this-&gt; getLayout返回null,导致getBlock调用抛出异常。
如果我禁用缓存没有出现错误,一切正常。
答案 0 :(得分:1)
您正在运行哪个版本?据我所知,Magento Enterprise 1.9在整页缓存方面存在严重问题。对不起,我的帮助不大。
答案 1 :(得分:1)
你刚刚在admin中禁用了缓存还是实际删除了/ var / cache?当您再次启用它时,Magento可能会使用旧的缓存页面导致错误。在缓存管理中有用于刷新缓存的按钮,或者您可以手动执行此操作。
答案 2 :(得分:1)
我刚刚将您的更改应用于Magento EE 1.9.1的库存安装,但我无法遇到您报告的错误。
只要我访问我的目录,该块就会正确更新,当我多次刷新页面时,它不会触发任何异常。
答案 3 :(得分:1)
从Varien获取1.9.1.1的补丁,它将起作用:
Index: app/code/core/Enterprise/PageCache/Model/Container/Catalognavigation.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Catalognavigation.php (revision 87812)
+++ app/code/core/Enterprise/PageCache/Model/Container/Catalognavigation.php (working copy)
@@ -133,6 +133,7 @@
$category = Mage::getModel('catalog/category')->load($categoryId);
Mage::register('current_category', $category);
}
+ $block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
Index: app/code/core/Enterprise/PageCache/Model/Container/Accountlinks.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Accountlinks.php (revision 87812)
+++ app/code/core/Enterprise/PageCache/Model/Container/Accountlinks.php (working copy)
@@ -71,6 +71,7 @@
$linkInfo['li_params'], $linkInfo['a_params'], $linkInfo['before_text'], $linkInfo['after_text']);
}
}
+ $block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
Index: app/code/core/Enterprise/PageCache/Model/Container/Orders.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Orders.php (revision 87812)
+++ app/code/core/Enterprise/PageCache/Model/Container/Orders.php (working copy)
@@ -63,6 +63,7 @@
$block = new $block;
$block->setTemplate($template);
+ $block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
Index: app/code/core/Enterprise/PageCache/Model/Container/Sidebar/Recentlycompared.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Sidebar/Recentlycompared.php (revision 87812)
+++ app/code/core/Enterprise/PageCache/Model/Container/Sidebar/Recentlycompared.php (working copy)
@@ -62,6 +62,7 @@
$block = new $block;
$block->setTemplate($template);
+ $block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
Index: app/code/core/Enterprise/PageCache/Model/Container/Sidebar/Comparelist.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Sidebar/Comparelist.php (revision 87812)
+++ app/code/core/Enterprise/PageCache/Model/Container/Sidebar/Comparelist.php (working copy)
@@ -60,6 +60,7 @@
$block = Mage::app()->getLayout()->createBlock('catalog/product_compare_list');
$block->setTemplate($template);
+ $block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
Index: app/code/core/Enterprise/PageCache/Model/Container/Messages.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Messages.php (revision 87812)
+++ app/code/core/Enterprise/PageCache/Model/Container/Messages.php (working copy)
@@ -81,6 +81,7 @@
foreach ($this->_messageStoreTypes as $type) {
$this->_addMessagesToBlock($type, $block);
}
+ $block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
Index: app/code/core/Enterprise/PageCache/Model/Container/Viewedproducts.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Viewedproducts.php (revision 87812)
+++ app/code/core/Enterprise/PageCache/Model/Container/Viewedproducts.php (working copy)
@@ -76,6 +76,7 @@
$block = new $block;
$block->setTemplate($template);
$block->setProductIds($productIds);
+ $block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
Index: app/code/core/Enterprise/PageCache/Model/Container/Wishlistlinks.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Wishlistlinks.php (revision 87812)
+++ app/code/core/Enterprise/PageCache/Model/Container/Wishlistlinks.php (working copy)
@@ -59,6 +59,7 @@
{
$block = $this->_placeholder->getAttribute('block');
$block = new $block;
+ $block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
}