简体   繁体   English

Magento-当我使用脚本更改数据库中的库存时,使用lesti fpc的特定产品清洁缓存

[英]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. 我的商店有超过8万种产品。 I have used Lesti_fpc to enhance its performance. 我使用了Lesti_fpc来增强其性能。 I add and remove products from the store using magmi. 我使用magmi在商店中添加和删除产品。 The products are provided by various vendors in the form of xml. 这些产品由各种供应商以xml的形式提供。 Thus we directly change product stock in the database using magmi. 因此,我们可以使用magmi直接更改数据库中的产品库存。 I want to clear the cache of those products whose stock is zero in the xml file. 我想清除xml文件中库存为零的那些产品的缓存。 I am calling the following function in the magmi script. 我在magmi脚本中调用以下函数。 I have included the save.php file of fpc in our script. 我已经在脚本中包含了fpc的save.php文件。 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. 然后在我们的脚本中创建Lesti_Fpc_Model_Observer_Save类的对象,并调用自定义函数(我在此类中创建了该函数),该函数如下所示。

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. 任何帮助表示赞赏。

This should works in your case. 这应该在您的情况下有效。 Change 1000012 by your Product Id. 通过产品ID更改1000012。

$cacheId = sha1("product_1000012");
$fpc = Mage::getModel('fpc/fpc');
$fpc->clean($cacheId);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM