2010-10-18 43 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(); 
    } 
} 
相關問題