0

When I disabled block_html cache tag then my code works fine.

I want to know how I can disable block_html programmatically in Magento for footer.phtml file?

SR_Magento
  • 5,209
  • 13
  • 62
  • 103
sanjana
  • 81
  • 1
  • 2

1 Answers1

2

There is method inside Mage_Core_Block_Abstract

/**
 * Load block html from cache storage
 *
 * @return string | false
 */
protected function _loadCache()
{
    if (is_null($this->getCacheLifetime()) || !$this->_getApp()->useCache(self::CACHE_GROUP)) {
        return false;
    }

As you can see the block will not be loaded from cache if its lifetime is null

Then open Footer Block file:

class Mage_Page_Block_Html_Footer extends Mage_Core_Block_Template
{

    protected $_copyright;

    protected function _construct()
    {
        $this->addData(array('cache_lifetime' => false));
        $this->addCacheTag(array(
            Mage_Core_Model_Store::CACHE_TAG,
            Mage_Cms_Model_Block::CACHE_TAG
        ));
    }

And all you need is put value 'null' instead of 'false'

$this->addData(array('cache_lifetime' => null));

Don't forget that magento strongly recommend do not edit core files.

zhartaunik
  • 3,848
  • 4
  • 23
  • 52