Somewhere around Magento 1.5, message from the title of this post begun to pop on every product save.
Although quite anoying, it is quite easy to fix and it seems that’s not a BUG, it is a feature – implemented without automatic block html cache refresh
I have tested it on Professional Edition and to be completely honest, I’m not sure if it will actually work on Magento CE,
but there is no reason why not (Please comment if it does).
Ok, what is the catch?!
Here we go:
Add this in your module config.xml:
<global>
<models>
<catalogrule>
<rewrite>
<rule>Yourpackage_Yourmodule_Model_Rule</rule>
</rewrite>
</catalogrule>
</models>
</global>
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();
}
}
}
Well…. that’s it :)
I hope it works for you as it works for me.
No comments:
Post a Comment