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?

2
  • Can we assume you are talking about EE FPC? Commented Nov 18, 2015 at 16:56
  • Oops. It's regarding Magento Enterprise FPC
    – beingalex
    Commented Nov 18, 2015 at 16:58

1 Answer 1

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 and acknowledge you have read our privacy policy.

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