public function getCacheKeyInfo() { $info = parent::getCacheKeyInfo(); $info[] = $this->getRequest()->getRequestUri(); $info[] = $this->getRequest()->getRequestString(); $info[] = Mage::app()->getStore()->getCurrentCurrencyCode(); $info[] = Mage::getSingleton('customer/session')->getCustomerGroupId(); return $info; }
/** * Returns array that uniquely identifies this product list in cache storage * * I have added the array keys: category_id, customer_group and website_id to ensure that we get correct product * prices in every instance of this product list * * @return array Cache key info * @throws Mage_Core_Exception */ public function getCacheKeyInfo() { // Get Magento's standard product list block cache key info $info = parent::getCacheKeyInfo(); // Dispatch event so others can modfify cache key info of this block without modifying module Mage::dispatchEvent('st_productlistblockcache_cache_info_add_before', array('cache_key_info' => $info)); /** @var Mage_Catalog_Model_Category|null $currentCategory Current category model or null */ $currentCategory = Mage::registry('current_category'); /** @var string $categoryId Current category id. Empty string if we don't know. */ $categoryId = ''; // If we know current category, then add category id to cache key info if ($currentCategory instanceof Mage_Catalog_Model_Category) { $categoryId = $currentCategory->getId(); } // Add category_id to cache key info $info['category_id'] = $categoryId; /** @var int $customerGroupId Get logged in user's customer group id */ $customerGroupId = (int) Mage::getSingleton('customer/session')->getCustomerGroupId(); // Add customer_group to cache key info $info['customer_group'] = $customerGroupId; /** @var int $currentWebsiteId Current website ID */ $currentWebsiteId = (int) Mage::app()->getWebsite()->getId(); // Add website_id to cache key info $info['website_id'] = $currentWebsiteId; /** @var string $layerStateKey */ $layerStateKey = $this->getLayer()->getStateKey(); $info['layer_state_key'] = $layerStateKey; /** @var string $formKey */ $formKey = Mage::getSingleton('core/session')->getFormKey(); $info['form_key'] = $formKey; /** @var string $originalRequestUri */ $originalRequestUri = Mage::app()->getRequest()->getOriginalRequest()->getRequestUri(); $info['request_uri'] = $originalRequestUri; // Current currency code $info['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode(); // Current locale code $info['locale'] = Mage::app()->getLocale()->getLocaleCode(); // Dispatch event so others can modfify cache key info of this block without modifying module Mage::dispatchEvent('st_productlistblockcache_cache_info_add_after', array('cache_key_info' => $info)); return $info; }