2010-10-18 15 views
5

Vì vậy, chúng tôi đã đặt khối "được xem gần đây" vào chế độ xem sản phẩm của chúng tôi. Tất cả mọi thứ có vẻ tốt lúc đầu, nhưng bây giờ tôi nhìn thấy lỗi lạ mà phải làm với null bố trí. Nếu tôi bật bộ nhớ đệm tắt nó hoạt động tốt, nhưng với bộ đệm ẩn trang đầy đủ cho phép nó không thành công khi gọi $ this-> getColumnCount(); trong mẫu.Magento: Di chuyển "Được xem gần đây" sang trang sản phẩm tạo lỗi bộ nhớ đệm lạ

Những gì tôi đã làm cho thời gian gần đây enable xem trên trang sản phẩm là:

trong catalog.xml bên trong khối nội dung của 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> 

trong mẫu file: Danh mục hàng/sản phẩm/xem .phtml:

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

mọi thứ đều tải tốt lần đầu tiên, nhưng sau đó nếu tôi nhấp vào chế độ xem sản phẩm khác, sau đó tải lại trang lỗi. Tôi đã truy tìm lỗi xuống lớp: Mage_Page_Helper_Layout.

chức năng getCurrentPageLayout(), có một dòng:

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

và $ this-> getLayout đang trở lại vô mà làm cho cuộc gọi getBlock để ném một ngoại lệ.
nếu tôi tắt bộ nhớ đệm, không có lỗi nào xuất hiện và mọi thứ hoạt động tốt.

+0

Có phải đó là trong Enterprise Edition? Nếu bạn nhìn vào 'ứng dụng/mã/lõi/Doanh nghiệp/PageCache/etc/cache.xml' có vẻ như cung cấp một giải pháp cho khối đó nhưng tôi không quen với tính năng này hoặc cách nó hoạt động. – clockworkgeek

+0

vâng phiên bản doanh nghiệp của nó. cảm ơn cho con trỏ. Tôi đang nhìn vào mã đó nhưng không thể có vẻ là một cách để tắt bộ nhớ đệm hoàn toàn cho khối đó. ngay cả khi tôi đặt cache_lifetime thành 1 nó vẫn mang lại cho tôi cùng một lỗi và nếu tôi lấy ra khối xml đó từ cache.xml, nó sẽ lưu trữ trang đó vô thời hạn và không cập nhật khi tôi nhấp vào các mục khác. – GeekPride

Trả lời

1

Bạn đang chạy phiên bản nào? Theo như tôi biết, Magento Enterprise 1.9 có vấn đề nghiêm trọng với Full Page Caching. Xin lỗi tôi không thể hữu ích hơn.

1

Bạn vừa vô hiệu hóa bộ nhớ đệm trong quản trị viên hoặc thực sự bị xóa/var/cache? Magento có thể sử dụng các trang đã lưu trong bộ nhớ cache cũ khi bạn bật lại nó gây ra lỗi. Có nút để xóa bộ đệm trong quản lý bộ nhớ cache hoặc bạn có thể thực hiện thủ công.

1

Tôi vừa mới áp dụng các thay đổi của bạn cho cài đặt cổ phiếu của Magento EE 1.9.1 và tôi không thể gặp phải lỗi bạn đã báo cáo.

Khối được cập nhật chính xác miễn là tôi truy cập vào danh mục của mình và nó không kích hoạt bất kỳ ngoại lệ nào khi tôi làm mới trang nhiều lần.

1

Hãy vá này từ Varien cho 1.9.1.1 và nó sẽ làm việc:

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(); 
    } 
} 
Các vấn đề liên quan