How to invalidate block cache after product attribute was edited. E.g. there is a multiselect attribte and if I edit its values in Magento admin I need the cache of the block to be deleted and refreshed.
There are many examples of how to do this when specific product was edited, e.g. on Magento forum: http://www.magentocommerce.com/wiki/5_-_modules_and_development/block_cache_and_html_ouput
protected function _construct()
{
$this->addData(array(
'cache_lifetime' => 120,
'cache_tags' => array(Mage_Catalog_Model_Product::CACHE_TAG . "_" . $this->getProduct()->getId()),
'cache_key' => $this->getProduct()->getId(),
));
}
but how to do this for attributes?
I've found the Mage_Eav_Model_Entity_Attribute::CACHE_TAG
constant for attributes but I'm not sure how to use it to delete the cache only when specific attribute was edited:
protected function _construct()
{
$this->addData(array(
'cache_lifetime' => 120,
'cache_tags' => array(Mage_Eav_Model_Entity_Attribute::CACHE_TAG),
'cache_key' => $product->getResource()->getAttribute('color')->getFrontend()->getValue($product),
));
}