From 189a5823663e49b34744a19480e9b005a22fc5f1 Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 14 May 2023 11:16:41 +0200 Subject: [PATCH 1/5] do not reindex disabled stores --- .../core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php index 38e6380b4c0..b337cf284d8 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php @@ -1401,6 +1401,7 @@ protected function _arrayNextKey(array $array, $key) public function reindexAll() { foreach (Mage::app()->getStores() as $storeId => $store) { + if (!$store->getIsActive()) continue; $this->prepareFlatTable($storeId); $this->beginTransaction(); try { From ffe2ab58532402e5b2dd93c72d9ab2c6cf905472 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sun, 14 May 2023 10:36:03 +0100 Subject: [PATCH 2/5] phpcs --- .../core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php index b337cf284d8..939d552d6ef 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php @@ -1401,7 +1401,9 @@ protected function _arrayNextKey(array $array, $key) public function reindexAll() { foreach (Mage::app()->getStores() as $storeId => $store) { - if (!$store->getIsActive()) continue; + if (!$store->getIsActive()) { + continue; + } $this->prepareFlatTable($storeId); $this->beginTransaction(); try { From 22f00e55ef8dc249de8570faa08313b765debf28 Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 14 May 2023 11:47:38 +0200 Subject: [PATCH 3/5] PHPCS complains --- .../core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php index b337cf284d8..939d552d6ef 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php @@ -1401,7 +1401,9 @@ protected function _arrayNextKey(array $array, $key) public function reindexAll() { foreach (Mage::app()->getStores() as $storeId => $store) { - if (!$store->getIsActive()) continue; + if (!$store->getIsActive()) { + continue; + } $this->prepareFlatTable($storeId); $this->beginTransaction(); try { From 4d13d282924072fdf03991b40ca2c81f94ee78a5 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 16 May 2023 18:05:34 +0200 Subject: [PATCH 4/5] add notice index rebuild message after enabled store --- app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php b/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php index 0554803998a..6d538fe6bed 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php +++ b/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php @@ -147,12 +147,13 @@ public function matchEvent(Mage_Index_Model_Event $event) $result = false; } } elseif ($entity == Mage_Core_Model_Store::ENTITY) { + Mage::log(__METHOD__); if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { $result = true; } else { /** @var Mage_Core_Model_Store $store */ $store = $event->getDataObject(); - if ($store && $store->isObjectNew()) { + if ($store && ($store->isObjectNew() || $store->getOrigData('is_active') != $store->getIsActive() && $store->getIsActive())) { $result = true; } else { $result = false; @@ -194,7 +195,7 @@ protected function _registerEvent(Mage_Index_Model_Event $event) if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { $this->_registerCoreStoreEvent($event); break; - } + } // no break case Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY: case Mage_Core_Model_Store_Group::ENTITY: From 29e531aed6595d457131015c2fc03584a38106a9 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 16 May 2023 18:13:33 +0200 Subject: [PATCH 5/5] clean --- app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php b/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php index cc0bfd5acab..ec0abf090e2 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php +++ b/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php @@ -146,7 +146,6 @@ public function matchEvent(Mage_Index_Model_Event $event) $result = false; } } elseif ($entity == Mage_Core_Model_Store::ENTITY) { - Mage::log(__METHOD__); if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { $result = true; } else { @@ -194,7 +193,7 @@ protected function _registerEvent(Mage_Index_Model_Event $event) if ($event->getType() == Mage_Index_Model_Event::TYPE_DELETE) { $this->_registerCoreStoreEvent($event); break; - } + } // no break case Mage_Catalog_Model_Resource_Eav_Attribute::ENTITY: case Mage_Core_Model_Store_Group::ENTITY: