Magento 马根托·唐';t缓存警报

Magento 马根托·唐';t缓存警报,magento,Magento,我已在我的Magento商店上安装了此扩展: 它确实缩短了目录列表的页面加载时间。问题是警报不再显示。例如,如果有人订阅产品,以便在产品重新进货时收到通知,则“重新加载”页面上会显示“已成功添加警报”消息 有人知道如何防止警报缓存吗 以下是扩展名中的代码: class Netresearch_CatalogCache_Block_Product_View extends Mage_Catalog_Block_Product_View /** * replace this parent

我已在我的Magento商店上安装了此扩展:

它确实缩短了目录列表的页面加载时间。问题是警报不再显示。例如,如果有人订阅产品,以便在产品重新进货时收到通知,则“重新加载”页面上会显示“已成功添加警报”消息

有人知道如何防止警报缓存吗

以下是扩展名中的代码:

    class Netresearch_CatalogCache_Block_Product_View extends Mage_Catalog_Block_Product_View
/**
 * replace this parent class by your inhereted version of th Product_View Block
 * e.g. class Netresearch_CatalogCache_Block_Product extends MyNameSpace_MyModule_Catalog_Block_Product_View
 */
{
    protected function _isCacheActive()
    {
        if(!Mage::getStoreConfig('catalog/frontend/cache_view')) {
            return false;
        }

        /* if there are any messages dont read from cache to show them */
        if(Mage::getSingleton('core/session')->getMessages(true)->count() > 0) {
            return false;
        }


        return true;
    }

    public function getCacheLifetime()
    {
        if($this->_isCacheActive())
        {
            return false;
        }
    }
/*
    protected function _loadCache()
    {
        $cache = parent::_loadCache();
        Mage::debug($cache===false? "computed":"from cache");
        return $cache;
    }
*/
    public function getCacheKey()
    {
        if(!$this->_isCacheActive()) {
            parent::getCacheKey();
        }
        $_taxCalculator = Mage::getModel('tax/calculation');
        $_customer = Mage::getSingleton('customer/session')->getCustomer();
        $_product = $this->getProduct();
        return 'ProductView'.
            /* Create differnet caches for ...
             * ... for different products */
            $_product->getId().'_'.
            /* ... for different stores */
            Mage::App()->getStore()->getCode().'_'.
            /* ... for different customer groups */
            $_customer->getGroupId().'_'.
      /* ADD CURRENCY CODE TO ID */
      Mage::app()->getStore()->getCurrentCurrencyCode().'_'.
            /* ... for different tax classes (related to customer and product) */
            $_taxCalculator->getRate(
                $_taxCalculator
                    ->getRateRequest()
                    ->setProductClassId($_product->getTaxClassId()
                )
            ).'_'.
            '';
    }


    public function getCacheTags()
    {
        if(!$this->_isCacheActive()) {
            return parent::getCacheTags();
        }
        return array(
            Mage_Catalog_Model_Product::CACHE_TAG,
            Mage_Catalog_Model_Product::CACHE_TAG."_".$this->getProduct()->getId()
        );

    }
}
我在这里问了一个关于商店货币的类似问题,得到了解决方案:

似乎正在检查
Mage::getSingleton('core/session')
以查看可显示的消息,最有可能的是新闻通讯模块将消息写入
Mage::getSingleton('customer/session'))
因此也需要对其进行检查

我不使用此模块,但已对Magento进行了缓存,并使用下面的代码来避免系统消息缓存。这对你有用吗?然后,您可以尝试:

protected function _isCacheActive()
{
    if(!Mage::getStoreConfig('catalog/frontend/cache_view')) {
        return false;
    }

    /* if there are any messages dont read from cache to show them */
    if($this->getMessagesBlock()->getGroupedHtml()) {
        return false;
    }


    return true;
}

事实上,只要有人加入购物车,我的缓存就会被冲掉。在进一步的调查中,我发现“Mage_Core_Block_Template”有默认的CACHE_GROUP='Block_html',这是Mage_Core_Block_Product_视图的父类。因此,在创建任何购物车时,都会从magento中清除block_html,这并不能解决问题


我的理解是正确的还是遗漏了什么?

我不确定,因为我还没有看过这个模块的代码,但它可能正在进行全页缓存。在这种情况下,如果您想继续使用该模块,您可以做的事情不多。如果只是缓存内容区域,我会将“警报”位置移到该区域之外。也许这会解决问题。事实上,我犯了一个错误。我的时事通讯提醒总是显示出来。这是“警报成功”消息,在用户单击“注册以在该消息返回库存时获得通知”链接后不会显示。您能否给出一个如何触发该消息的示例?例如,确切的网页网址或可能你有演示。我以前从未面对过。它可能在
Mage::getSingleton('catalog/session')
中设置,但我已经使用探查器验证了这一点,当任何其他用户添加到购物车时,查询数突然增加到等于未缓存状态数。使用Magento调试来验证这一点。还有谁注意到了这一点?有什么办法可以解决这个问题吗?似乎必须购买一些用于缓存的模块,但我确定这是否也包含在其中