简体   繁体   English

Magento刷新块缓存

[英]Magento Flush Block Cache

In Magento CE 1.4.1.1, I have added block cache to product view page. 在Magento CE 1.4.1.1中,我向产品视图页面添加了块缓存。 So the frontend product page will be cached after first visit, so far so good. 因此到目前为止,前端产品页面将在第一次访问后被缓存。

however, I found that even if someone purchased that product, the block cache was not flushed. 但是,我发现即使有人购买了该产品,块缓存也没有被刷新。 This is not good because then in the frontend, the product page will show wrong inventory/stock information, also no way to show alert message once the product page is cached. 这不好,因为在前端,产品页面将显示错误的库存/库存信息,一旦产品页面被缓存,也将无法显示警报消息。 (seems like the product block cache is only flushed when I save the product in backend admin) (似乎仅当我将产品保存在后端管理员中时才刷新产品阻止缓存)

1) any expert can show how to flush the block cache for a particular product? 1)任何专家都可以展示如何刷新特定产品的块缓存?

2) along the same line, if I want to cache category page since I am using ajax layered navigation (and ajax paging, ajax sort order), how to add exclude cache condition on the above areas? 2)沿着同一行,如果由于要使用ajax分层导航(以及ajax分页,ajax排序顺序)而要缓存类别页面,如何在上述区域添加排除缓存条件?

Thanks 谢谢

It is hard to say how to achieve this without seeing your code and knowing how your page cache is implemented, but on possible solution is to create an observer that will clear cache for all products ordered 很难说如何在不看代码的情况下以及不知道如何实现页面缓存的情况下实现这一目标,但是可能的解决方案是创建一个观察者,该观察者将清除所有订购产品的缓存。

In /app/code/local/MageIgniter/ClearProductCache/etc/config.xml 在/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>
 ....

In /app/code/local/MageIgniter/ClearProductCache/Model/Observer.php 在/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;
    }

See Implementing observer Magento 请参阅实施观察者Magento

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM