Magento Tips & Tricks

Magento Static blocks issues

Recently we have updated our demo site to 1.9.2 and notice strange behaviour of static blocks. Magento was showing wrong static blocks.
After some research it turns out that it is known issue and moreover, there is an open bug for this

This happens due to the following code being added to the constructor of Mage_Cms_Block_Block:

It adds cache functionality to static blocks. But cache key info is generated in Mage_Core_Block_Abstract, which use block name in layout. Block name does not exist since static block are not added though layout, and as a result they have the same cache key.

To fix it we have created simple extension. It override Mage_Cms_Block_Block to generate correct cache key info for each static block based on store id, block id and secure connection.
Source code on Github

  1. Create /app/etc/modules/Nwdthemes_Cmsfix.xml
  2. Create /app/code/local/Nwdthemes/Cmsfix/etc/config.xml
  3. Create /app/code/local/Nwdthemes/Cmsfix/Block/Block.php

  4. Thats it. CMS static blocks issue solved.
    Source code on Github

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.