Last active
September 10, 2015 02:55
-
-
Save ryaan-anthony/be418be99089fd5854bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 My_Foo_Block_Thing extends Mage_Core_Block_Template | |
| { | |
| protected $_cacheKey = "your-cache-key"; | |
| protected function _construct() | |
| { | |
| $this->addData([ | |
| 'cache_lifetime'=> false, | |
| 'cache_tags' => [ | |
| Mage_Core_Model_Store::CACHE_TAG, | |
| Mage_Cms_Model_Block::CACHE_TAG | |
| ] | |
| ]); | |
| parent::_construct(); | |
| } | |
| /** | |
| * Get cache key informative items | |
| * | |
| * @return array | |
| */ | |
| public function getCacheKeyInfo() | |
| { | |
| /** @var Mage_Customer_Model_Session $customerSession */ | |
| $customerSession = Mage::getSingleton('customer/session'); | |
| return [ | |
| $this->_cacheKey, | |
| Mage::app()->getStore()->getId(), | |
| (int)Mage::app()->getStore()->isCurrentlySecure(), | |
| Mage::getDesign()->getPackageName(), | |
| Mage::getDesign()->getTheme('template'), | |
| $customerSession->isLoggedIn() ? $customerSession->getCustomerId() : 'guest' | |
| ]; | |
| } | |
| /** | |
| * Retrieve child block HTML, sorted by default | |
| * | |
| * @param string $name | |
| * @param boolean $useCache | |
| * @return string | |
| */ | |
| public function getChildHtml($name='', $useCache=true, $sorted=true) | |
| { | |
| return parent::getChildHtml($name, $useCache, $sorted); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment