2012-12-23 117 views
0

在Magento CE 1.4.1.1中,我已经将块缓存添加到产品视图页面。所以前端产品页面会在第一次访问后被缓存,到目前为止非常好。Magento刷新块缓存

但是,我发现即使有人购买了该产品,块缓存也不会被刷新。这不好,因为在前端,产品页面会显示错误的库存/库存信息,一旦产品页面被缓存,也无法显示警报消息。 (看起来像产品块缓存只在我将产品保存在后端管理员时刷新)

1)任何专家都可以显示如何刷新特定产品的块缓存? 2)沿同一行,如果我想缓存类别页面,因为我使用ajax分层导航(和ajax分页,ajax排序顺序),如何在上面的区域添加排除缓存条件?

感谢

回答

0

这是很难说如何做到这一点,没有看到你的代码,并了解你的页面缓存是如何实现的,但可能的解决方案是创建一个观察者,将清除缓存的所有产品订购

在/app/code/local/MageIgniter/ClearProductCache/etc/config.xml

.... 
    <events> 
     <sales_order_place_after> 
      <observers> 
       <clearproductcache> 
        <type>singleton</type> 
        <class>clearproductcache/observer</class> 
        <method>implementClearProductCache</method> 
       </clearproductcache> 
      </observers> 
     </sales_order_place_after> 
.... 

在/app/code/local/MageIgniter/ClearProductCache/Model/Observer.php

<?php 
class MageIgniter_ClearProductCache_Model_Observer 
{ 
    public function implementClearProductCache($event) 
    { 

     $_order = $event->getOrder(); 

     foreach ($_order->getAllItems() as $item) { 
      //call function to clear cahced 
      //$item->getId(); 
     } 


     return $this; 
    } 

请参阅Implementing observer Magento