1

We want to clear the full page cache for a specific product - based on the ID of the product (or the URL if needs be). I have found this line:

Mage::app()->cleanCache('catalog_product_'.$this->getId());

In app/code/core/Mage/Catalog/Model/Product.php:

public function cleanCache()
{
    Mage::app()->cleanCache('catalog_product_'.$this->getId());
    return $this;
}   

I tried using this like:

Mage::app()->cleanCache('catalog_product_1234');

But it doesn't work. How can we clear the FPC just for one specific product?

  • Can we assume you are talking about EE FPC? – Jonathan Hussey Nov 18 '15 at 16:56
  • Oops. It's regarding Magento Enterprise FPC – beingalex Nov 18 '15 at 16:58
0

if you look into Mage_PageCache_Model_Observer_Index

protected function _cleanEntityCache(Mage_Core_Model_Abstract $entity, array $ids)
        {
            $cacheTags = array();
            foreach ($ids as $entityId) {
                $entity->setId($entityId);
                $cacheTags = array_merge($cacheTags, $entity->getCacheIdTags());
            }
            if (!empty($cacheTags)) {
                Mage_PageCache_Model_Cache::getCacheInstance()->clean($cacheTags);
            }
        }

So it looks you should do something like:

 $cacheTags = $product->getCacheIdTags();
 Mage_PageCache_Model_Cache::getCacheInstance()->clean($cacheTags);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.