Magento – how to disable cache for cms block

cachecatalogcategory

unfortunately in this situation I do not have $this->getChildHtml to assign false to it and then change my xml file for disabling cache I have this block in view.phtml:

    <?php echo $this->getCmsBlockHtml() ?>

and the function is in view.php as follow:

public function getCmsBlockHtml()
{
    if (!$this->getData('cms_block_html')) {
        $html = $this->getLayout()->createBlock('cms/block')
            ->setBlockId($this->getCurrentCategory()->getLandingPage())
            ->toHtml();
        $this->setData('cms_block_html', $html);
    }
    return $this->getData('cms_block_html');
}

any ideas on how to disable the cache here? my page is in category folder when displaying the products

Update:with help of Denis I understood that (for some pages) when I have something in constructor if the cache is enabled the constructor will not be called! and so I think that's the reason why setting the cache life time doesn't work there

Best Answer

To disable Block Html Cache you should set cacheLifeTime to null. You can see more details in Mage_Core_Block_Abstract::_loadCache()

protected function _loadCache()
{
    if (is_null($this->getCacheLifetime()) || !$this->_getApp()->useCache(self::CACHE_GROUP)) {
        return false;
    }
    ...
}
Related Topic