From 1254a7341d2d238af7d7b887b99151c8196a097b Mon Sep 17 00:00:00 2001 From: Roy Duineveld Date: Wed, 13 Jul 2016 09:37:00 +0200 Subject: [PATCH] Clear category caches after product (mass)save --- .../Lesti/Fpc/Model/Observer/Save.php | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/code/community/Lesti/Fpc/Model/Observer/Save.php b/app/code/community/Lesti/Fpc/Model/Observer/Save.php index c07a0d0..ae5c357 100644 --- a/app/code/community/Lesti/Fpc/Model/Observer/Save.php +++ b/app/code/community/Lesti/Fpc/Model/Observer/Save.php @@ -28,16 +28,11 @@ public function catalogProductSaveAfter($observer) if ($product->getId()) { $this->_getFpc()->clean(sha1('product_' . $product->getId())); - $origData = $product->getOrigData(); - if (empty($origData) - || (!empty($origData) && $product->dataHasChangedFor('status')) - ) { - $categories = $product->getCategoryIds(); - foreach ($categories as $categoryId) { - $this->_getFpc()->clean( - sha1('category_' . $categoryId) - ); - } + $categories = $product->getCategoryIds(); + foreach ($categories as $categoryId) { + $this->_getFpc()->clean( + sha1('category_' . $categoryId) + ); } } } @@ -152,6 +147,14 @@ protected function _catalogProductSaveAfterMassAction(array $productIds) $tags = array(); foreach ($productIds as $productId) { $tags[] = sha1('product_' . $productId); + + $product = Mage::getModel('catalog/product')->load($productId); + $categories = $product->getCategoryIds(); + foreach ($categories as $categoryId) { + $this->_getFpc()->clean( + sha1('category_' . $categoryId) + ); + } } $this->_getFpc()->clean($tags); }