Magento Flush Block Cache

时间:2012-12-23 17:08:06

标签: magento caching

在Magento CE 1.4.1.1中,我已将块缓存添加到产品视图页面。所以前端产品页面将在首次访问后进行缓存,到目前为止一直很好。

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

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

2)沿着同一行,如果我想缓存类别页面,因为我使用ajax分层导航(和ajax分页,ajax排序),如何在上面的区域添加排除缓存条件?

由于

1 个答案:

答案 0 :(得分: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

相关问题