Wednesday 15 June 2011

One or more of the Cache Types are invalidated: Blocks HTML output

In Magento 1.5 displaying message to pop on every product save.

If you go to system -> Cache management -> (Invalid )option


Here is the solution  ....

Add this in your module config.xml:


<global>
<models>
<catalogrule>
    <rewrite>
        <rule>Yourpackage_Yourmodule_Model_Rule</rule>
    </rewrite>
</catalogrule>
</models>

Create file called Rule.php in YOUR module Model directory.

Add this code in newly created file:




class Yourpackage_Yourmodule_Model_Rule extends Mage_CatalogRule_Model_Rule
{
   /**
     * Apply all price rules to product
     *
     * @param int|Mage_Catalog_Model_Product $product
     * @return Mage_CatalogRule_Model_Rule
     */
    public function applyAllRulesToProduct($product)
    {
        $this->_getResource()->applyAllRulesForDateRange(NULL, NULL, $product);
        $this->_invalidateCache();
        //Notice this little line
    Mage::app()->getCacheInstance()->cleanType('block_html');
        $indexProcess = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
        if ($indexProcess) {
            $indexProcess->reindexAll();
        }
    }
}


3 comments:

  1. I wrote an extension that does this for you. But does not use rewrite, but based off an event. Better to use events than rewrites. http://www.iuvocommerce.com/blockcache-extension.html

    ReplyDelete
  2. We developed simple bugfix for this issue.

    Visit http://magento.modulabs.com/mage_en/general-others/magento-bugfix-avoid-to-message.html

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete