From f675b86e2fe6f8f93e38e02f4bf46c186e5e3e96 Mon Sep 17 00:00:00 2001 From: Romain Ruaud Date: Fri, 3 Jun 2016 18:46:41 +0200 Subject: [PATCH 1/2] Ensure callback application only on an already existing category. --- .../Plugin/Catalog/Category/SaveProductsPositions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module-elasticsuite-virtual-category/Plugin/Catalog/Category/SaveProductsPositions.php b/src/module-elasticsuite-virtual-category/Plugin/Catalog/Category/SaveProductsPositions.php index 33a85c854..5c314397b 100644 --- a/src/module-elasticsuite-virtual-category/Plugin/Catalog/Category/SaveProductsPositions.php +++ b/src/module-elasticsuite-virtual-category/Plugin/Catalog/Category/SaveProductsPositions.php @@ -69,7 +69,7 @@ public function aroundSave( \Closure $proceed, \Magento\Framework\Model\AbstractModel $category ) { - if ($category->getSortedProducts()) { + if ($category->getId() && $category->getSortedProducts()) { $this->unserializeProductPositions($category); $categoryResource->addCommitCallback( From 89d22f20f8688995581ae6b51b73d1f8f56538e9 Mon Sep 17 00:00:00 2001 From: Romain Ruaud Date: Fri, 3 Jun 2016 18:49:41 +0200 Subject: [PATCH 2/2] Ignore categories having a level lower than or equal to 1 when reindexing. --- .../Indexer/Category/Save/ReindexCategoryAfterSave.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/module-elasticsuite-catalog/Plugin/Indexer/Category/Save/ReindexCategoryAfterSave.php b/src/module-elasticsuite-catalog/Plugin/Indexer/Category/Save/ReindexCategoryAfterSave.php index eb369d1ca..d47571f0c 100644 --- a/src/module-elasticsuite-catalog/Plugin/Indexer/Category/Save/ReindexCategoryAfterSave.php +++ b/src/module-elasticsuite-catalog/Plugin/Indexer/Category/Save/ReindexCategoryAfterSave.php @@ -51,9 +51,10 @@ public function aroundReindex( ) { $proceed(); - $categoryIndexer = $this->indexerRegistry->get(\Smile\ElasticSuiteCatalog\Model\Category\Indexer\Fulltext::INDEXER_ID); - - $categoryIndexer->reindexRow($subject->getId()); + if ($subject->getLevel() > 1) { + $categoryIndexer = $this->indexerRegistry->get(\Smile\ElasticSuiteCatalog\Model\Category\Indexer\Fulltext::INDEXER_ID); + $categoryIndexer->reindexRow($subject->getId()); + } return; }