Mage_CatalogIndex_Model_Aggregation Class Reference

Inheritance diagram for Mage_CatalogIndex_Model_Aggregation:

Mage_Core_Model_Abstract Varien_Object

List of all members.

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)


Detailed Description

Index data aggregation model

Allow cache some aggregated data with tag dependency

Definition at line 32 of file Aggregation.php.


Member Function Documentation

_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

Parameters:
string $key
Returns:
string

Definition at line 135 of file Aggregation.php.

00136     {
00137         return $key;
00138         return md5($key);
00139     }

_processTags ( tags  )  [protected]

Process tags array

this method split tags like "category:1,2,3" to four different tags: category, category1, category2, category3

Parameters:
unknown_type $tags
Returns:
unknown

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

Parameters:
array $tags
int|null|string $store
Returns:
Mage_CatalogIndex_Model_Aggregation

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

Parameters:
int|array $productIds
Returns:
Mage_CatalogIndex_Model_Aggregation

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

Parameters:
string $key
null|int|string|Mage_Core_Model_Store $store
Returns:
array|null

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

Parameters:
string $key
array $tags
null|int|string|Mage_Core_Model_Store $store
Returns:
Mage_CatalogIndex_Model_Aggregation

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     }


Member Data Documentation

const CACHE_FLAG_NAME = 'layered_navigation'

Definition at line 34 of file Aggregation.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:46 2009 for Magento by  doxygen 1.5.8