Last active
August 29, 2015 14:05
-
-
Save ivanweiler/694c0aaf23deab2a38a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Inchoo_Edu_Model_Resource_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract | |
{ | |
/* | |
* Collection that always caches all its queries | |
* | |
*/ | |
protected function _construct() | |
{ | |
$this->_init('inchoo_edu/dummy'); | |
$this->initCache( | |
Mage::app()->getCache(), | |
'dummy_collection', | |
array() | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Inchoo_Edu_Model_Example | |
{ | |
public function getCachedCollection() | |
{ | |
//Mage_Core_Model_Resource_Db_Collection_Abstract | |
$collection = Mage::getModel('catalog/product')->getCollection() | |
->addAttributeToSelect(array('name', 'image', 'url')) | |
->addPriceData() | |
->addUrlRewrite(); | |
$collection->initCache( | |
Mage::app()->getCache(), | |
'INCHOO_EDU_PRODUCTS', | |
array(Mage_Catalog_Model_Product::CACHE_TAG) | |
); | |
return $collection; | |
/* | |
$websiteCollection = Mage::getModel('core/website')->getCollection() | |
->initCache( | |
Mage::app()->getCache(), | |
'app', | |
array(Mage_Core_Model_Website::CACHE_TAG) | |
) | |
->setLoadDefault(true); | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment