Public Member Functions | |
getCacheData ($key, $store=null) | |
saveCacheData ($data, $key, $tags, $store=null) | |
clearCacheData ($tags=array(), $store=null) | |
clearProductData ($productIds) | |
Public Attributes | |
const | CACHE_FLAG_NAME = 'layered_navigation' |
Protected Member Functions | |
_construct () | |
_isEnabled () | |
_processKey ($key) | |
_processTags ($tags) |
Allow cache some aggregated data with tag dependency
Definition at line 32 of file Aggregation.php.
_construct | ( | ) | [protected] |
Initialize resource model
Reimplemented from Varien_Object.
Definition at line 39 of file Aggregation.php.
00040 { 00041 $this->_init('catalogindex/aggregation'); 00042 }
_isEnabled | ( | ) | [protected] |
Definition at line 44 of file Aggregation.php.
00045 { 00046 return Mage::app()->useCache(self::CACHE_FLAG_NAME); 00047 }
_processKey | ( | $ | key | ) | [protected] |
Prepare data key
string | $key |
Definition at line 135 of file Aggregation.php.
_processTags | ( | $ | tags | ) | [protected] |
Process tags array
this method split tags like "category:1,2,3" to four different tags: category, category1, category2, category3
unknown_type | $tags |
Definition at line 150 of file Aggregation.php.
00151 { 00152 $newTags = array(); 00153 foreach ($tags as $tag) { 00154 $tagInfo = split(':', $tag); 00155 if (count($tagInfo)==1) { 00156 $newTags[] = $tagInfo[0]; 00157 } else { 00158 $tagVariants = split('/', $tagInfo[1]); 00159 foreach ($tagVariants as $tagVariant) { 00160 $newTags[] = $tagInfo[0] . $tagVariant; 00161 } 00162 } 00163 } 00164 return $newTags; 00165 }
clearCacheData | ( | $ | tags = array() , |
|
$ | store = null | |||
) |
Delete cached aggreagation data
array | $tags | |
int|null|string | $store |
Definition at line 100 of file Aggregation.php.
00101 { 00102 $tags = $this->_processTags($tags); 00103 if ($store !== null) { 00104 $store = Mage::app()->getStore($store)->getId(); 00105 } 00106 $this->_getResource()->clearCacheData($tags, $store); 00107 return $this; 00108 }
clearProductData | ( | $ | productIds | ) |
Clear all cache data related with products
int|array | $productIds |
Definition at line 116 of file Aggregation.php.
00117 { 00118 $categoryPaths = $this->_getResource()->getProductCategoryPaths($productIds); 00119 if (!empty($categoryPaths)) { 00120 $tags = array(); 00121 foreach ($categoryPaths as $path) { 00122 $tags[] = Mage_Catalog_Model_Category::CACHE_TAG.':'.$path; 00123 } 00124 $this->clearCacheData($tags); 00125 } 00126 return $this; 00127 }
getCacheData | ( | $ | key, | |
$ | store = null | |||
) |
Get aggregated data by data key and store
string | $key | |
null|int|string|Mage_Core_Model_Store | $store |
Definition at line 56 of file Aggregation.php.
00057 { 00058 if (!$this->_isEnabled()) { 00059 return null; 00060 } 00061 00062 $key = $this->_processKey($key); 00063 $store = Mage::app()->getStore($store); 00064 $data = $this->_getResource()->getCacheData($key, $store->getId()); 00065 if (empty($data)) { 00066 return null; 00067 } 00068 return $data; 00069 }
saveCacheData | ( | $ | data, | |
$ | key, | |||
$ | tags, | |||
$ | store = null | |||
) |
Save aggregation data to cache
string | $key | |
array | $tags | |
null|int|string|Mage_Core_Model_Store | $store |
Definition at line 79 of file Aggregation.php.
00080 { 00081 if (!$this->_isEnabled()) { 00082 return $this; 00083 } 00084 00085 $key = $this->_processKey($key); 00086 $tags = $this->_processTags($tags); 00087 $store = Mage::app()->getStore($store); 00088 00089 $this->_getResource()->saveCacheData($data, $key, $tags, $store->getId()); 00090 return $this; 00091 }
const CACHE_FLAG_NAME = 'layered_navigation' |
Definition at line 34 of file Aggregation.php.