Magento - 不要缓存货币

时间:2011-11-01 12:05:22

标签: magento

我在Magento商店安装了此扩展程序: http://www.magentocommerce.com/magento-connect/catalogcache.html

它确实改善了目录列表的页面加载时间。问题是如果我更改了商店货币,它将不会在页面上更新,并且缓存的货币将继续显示。任何想法如何使货币变化生效?

以下是扩展程序中的代码:

class Netresearch_CatalogCache_Block_Product_List extends Mage_Catalog_Block_Product_List
{
    protected function _isCacheActive()
    {
        if(!Mage::getStoreConfig('catalog/frontend/cache_list')) {
            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 2419200;;
        }
    }
/*
    protected function _loadCache()
    {

        $cache = parent::_loadCache();
        Mage::debug($cache === false ? "computed" : "from cache");
        return $cache;
    }
*/
    public function getCacheKey()
    {
        if(!$this->_isCacheActive()) {
            parent::getCacheKey();
        }
        $_taxRateRequest = Mage::getModel('tax/calculation')->getRateRequest();
        $_customer = Mage::getSingleton('customer/session')->getCustomer();
        $this->_category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
        $_page = $this->getPage();

        $toolbar = new Mage_Catalog_Block_Product_List_Toolbar();
        $return = 'ProductView_'.
            /* Create differnet caches for differnt...
             * ... categories */
            $this->_category->getId().'_'.
            /* ... orders */
            $toolbar->getCurrentOrder().'_'.
            /* ... direction */
            $toolbar->getCurrentDirection().'_'.
            /* ... mode */
            $toolbar->getCurrentMode().'_'.
            /* ... page */
            $toolbar->getCurrentPage().'_'.
            /* ... items per page */
            $toolbar->getLimit().'_'.
            /* ... stores */
            Mage::App()->getStore()->getCode().'_'.
            /* ... customer groups */
            $_customer->getGroupId().'_'.
            $_taxRateRequest->getCountryId()."_".$_taxRateRequest->getRegionId()."_".$_taxRateRequest->getPostcode()."_".$_taxRateRequest->getCustomerClassId()."_".
            /* ... tags */
            Mage::registry('current_tag').'_'.
            '';
            /* ... layern navigation + search */
            foreach(Mage::app()->getRequest()->getParams() as $key=>$value) {
                $return .= $key.'-'.$value.'_';
            }
        return $return;
    }


    public function getCacheTags()
    {
        if(!$this->_isCacheActive()) {
            return parent::getCacheTags();
        }
        $cacheTags = array(
            Mage_Catalog_Model_Category::CACHE_TAG,
            Mage_Catalog_Model_Category::CACHE_TAG.'_'.$this->_category->getId()
        );
        foreach($this->_getProductCollection() as $_product) {
            $cacheTags[] = Mage_Catalog_Model_Product::CACHE_TAG."_".$_product->getId();
        }
        return $cacheTags;

    }
}

此处还讨论了货币缓存,但我仍然不确定该怎么做: http://www.magentocommerce.com/boards/viewthread/41112/

1 个答案:

答案 0 :(得分:2)

您可以尝试为货币代码添加唯一ID:

        /* ... items per page */
        $toolbar->getLimit().'_'.
        /* ... stores */
        Mage::App()->getStore()->getCode().'_'.
        /*** ADD CURRENCY CODE TO ID ***/
        Mage::app()->getStore()->getCurrentCurrencyCode().'_'.
        /* ... customer groups */
        $_customer->getGroupId().'_'.