本文整理汇总了PHP中Mage_Catalog_Block_Product_List::getCacheKeyInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Block_Product_List::getCacheKeyInfo方法的具体用法?PHP Mage_Catalog_Block_Product_List::getCacheKeyInfo怎么用?PHP Mage_Catalog_Block_Product_List::getCacheKeyInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Block_Product_List
的用法示例。
在下文中一共展示了Mage_Catalog_Block_Product_List::getCacheKeyInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCacheKeyInfo
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;
}
示例2: getCacheKeyInfo
/**
* 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;
}