Aligent_CacheObserver_Model_Resource_Catalog_Category::load PHP Метод

load() публичный Метод

Loads the category, implementing specific rules for caching
public load ( Mage_Catalog_Model_Category $oCategory, string | integer $id, array $attributes = [] ) : self
$oCategory Mage_Catalog_Model_Category
$id string | integer
$attributes array
Результат self
    public function load($oCategory, $id, $attributes = array())
    {
        if (null !== $attributes || !Mage::app()->useCache('catalog_models')) {
            return parent::load($oCategory, $id, $attributes);
        }
        // Caching product data
        Varien_Profiler::start(__METHOD__);
        $storeId = (int) $oCategory->getStoreId();
        $cacheId = "category-{$id}-{$storeId}";
        if ($cacheContent = Mage::app()->loadCache($cacheId)) {
            $data = unserialize($cacheContent);
            if (!empty($data)) {
                $oCategory->setData($data);
            }
        } else {
            parent::load($oCategory, $id, $attributes);
            // You can call some heavy methods here
            try {
                $cacheContent = serialize($oCategory->getData());
                $tags = array(Mage_Catalog_Model_Category::CACHE_TAG, Mage_Catalog_Model_Category::CACHE_TAG . '_' . $id);
                $lifetime = Mage::getStoreConfig('core/cache/lifetime');
                Mage::app()->saveCache($cacheContent, $cacheId, $tags, $lifetime);
            } catch (Exception $e) {
                // Exception = no caching
                Mage::logException($e);
            }
        }
        Varien_Profiler::stop(__METHOD__);
        return $this;
    }
Aligent_CacheObserver_Model_Resource_Catalog_Category