【问题标题】:Magento Flush Block CacheMagento 刷新块缓存
【发布时间】:2012-12-10 09:02:52
【问题描述】:

在 Magento CE 1.4.1.1 中,我在产品视图页面中添加了块缓存。所以前端产品页面在第一次访问后会被缓存,到目前为止一切顺利。

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

1) 任何专家都可以展示如何刷新特定产品的块缓存?

2)同理,如果我使用ajax分层导航(以及ajax分页、ajax排序),想缓存分类页面,如何在上述区域添加排除缓存条件?

谢谢

【问题讨论】:

    标签: magento caching


    【解决方案1】:

    如果不查看您的代码并知道您的页面缓存是如何实现的,很难说如何实现这一点,但可能的解决方案是创建一个观察者,它将清除所有订购产品的缓存

    在/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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-30
      • 1970-01-01
      • 2022-01-08
      相关资源
      最近更新 更多