Magento-不要缓存货币 [英] Magento - Don't Cache Currency
问题描述
我已经在我的Magento商店中安装了此扩展程序: http://www.magentocommerce.com/magento-connect/catalogcache.html
I had installed this extension on my Magento store: http://www.magentocommerce.com/magento-connect/catalogcache.html
它确实缩短了目录列表的页面加载时间.问题是,如果我更改了商店货币,则页面上将不会更新它,并且缓存的货币将继续显示.有什么想法可以使货币变化生效吗?
It really improved the page load time for the catalog listings. The problem is if I changed the store currency it wouldn't get updated on the page and the cached currency would continue to display. Any ideas how I can make it so that currency changes will take effect?
这是扩展名中的代码:
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/ >
Currency caching is also discussed here but I'm still not sure what to do: http://www.magentocommerce.com/boards/viewthread/41112/
推荐答案
您可以尝试为您的货币代码添加唯一的ID:
You can try and add a unique ID for your Currency codes:
/* ... items per page */
$toolbar->getLimit().'_'.
/* ... stores */
Mage::App()->getStore()->getCode().'_'.
/*** ADD CURRENCY CODE TO ID ***/
Mage::app()->getStore()->getCurrentCurrencyCode().'_'.
/* ... customer groups */
$_customer->getGroupId().'_'.
这篇关于Magento-不要缓存货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!