How to clear single product fpc cache in magento?

Magento - Specific product clean cache using lesti fpc when i change stock in the database using script

  • I have a store with over 80K products. I have used Lesti_fpc to enhance its performance. I add and remove products from the store using magmi. The products are provided by various vendors in the form of xml. Thus we directly change product stock in the database using magmi. I want to clear the cache of those products whose stock is zero in the xml file. I am calling the following function in the magmi script. I have included the save.php file of fpc in our script. then created an object of the class Lesti_Fpc_Model_Observer_Save in our script, and called a custom function (which I have created in this class) the function is as below. public function clearProductCache($productId = null) { //$this->_getFpc()->clean(sha1('product_' . $productId)); $this->_getFpc()->clean($productId); die('test'); } this function executes but the cache does not clear. Any help is appreciated.

  • Answer:

    This should works in your case. Change 1000012 by your Product Id. $cacheId = sha1("product_1000012"); $fpc = Mage::getModel('fpc/fpc'); $fpc->clean($cacheId);

user3505489 at Stack Overflow Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.