Last active
November 29, 2015 03:48
-
-
Save iods/619af0b11a18fef22955 to your computer and use it in GitHub Desktop.
Cache blocks in Magento.
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 | |
| /** | |
| * Observer to core_block_abstract_to_html_before | |
| * | |
| * Specifies required cache information like key (block id) | |
| * and tag (Mage_Cms_Model_Block::CACHE_TAG). | |
| */ | |
| public function cmsBlockCache($observer) | |
| { | |
| if ($block instanceof Mage_Cms_Block_Widget_Block || $block instanceof Mage_Cms_Block_Block) | |
| { | |
| $cacheKeyData = array( | |
| Mage_Cms_Model_Block::CACHE_TAG, | |
| $block->getBlockId(), | |
| Mage::app()->getStore()->getId() | |
| ); | |
| $block->setCacheKey(implode('_', $cacheKeyData)); | |
| $block->setCacheTags( | |
| Mage_Cms_Model_Block::CACHE_TAG | |
| ); | |
| $block->setCacheLifetime(false); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment