2010-10-18 44 views
5

因此,我们已将“最近浏览过的”模块放入我们的产品视图中。一切看起来都很好,但我现在看到奇怪的错误,这与空布局有关。如果我关闭缓存工作正常,但启用完整页面缓存失败时调用$ this-> getColumnCount();在模板中。Magento:将“最近浏览”移动到产品页面会产生奇怪的缓存错误

我所做的产品页面上启用最近查看的是:

在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> 
在模板文件

:目录/产品/图一个.phtml:

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

一切加载罚款的第一次,但当时如果我在其他产品视图中单击,然后重新加载页面的错误它出来。我将错误追溯到类:Mage_Page_Helper_Layout。

功能getCurrentPageLayout(),有一行:

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

和$这个 - > getLayout被返回null这将导致getBlock调用抛出异常。
如果我禁用缓存没有错误出现,一切工作正常。

+0

的是,在企业版?如果你看看'app/code/core/Enterprise/PageCache/etc/cache.xml',它似乎提供了一个解决方案,但我不熟悉该功能或它的工作原理。 – clockworkgeek 2010-10-18 19:41:18

+0

是它的企业版。感谢指针。我正在研究该代码,但似乎无法完全关闭该块的缓存。即使我将cache_lifetime设置为1,它仍然给我相同的错误,并且如果我从cache.xml中取出该xml块,它只会无限期地缓存该页面,并且在我单击其他项目时不会更新。 – GeekPride 2010-10-18 22:14:10

回答

1

你正在运行哪个版本?据我所知,Magento Enterprise 1.9在全页面缓存方面存在严重问题。对不起,我不能更有帮助。

1

你刚刚在管理员中禁用缓存或实际上删除了/ var/cache?当您再次启用它时会导致错误,Magento可能会使用旧的缓存页面。在缓存管理中有用于清空缓存的按钮,或者您可以手动执行。

1

我刚刚应用您的更改到Magento EE 1.9.1的股票安装,我无法体验您报告的错误。

只要我访问我的目录,该块就会正确更新,并且当我多次刷新页面时不会触发任何异常。

1

采取从瓦瑞恩这个补丁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(); 
    } 
} 
相关问题