From e8a97478496cebb7b43c125d254746cc84dacf6d Mon Sep 17 00:00:00 2001 From: m-milewski <32764961+m-milewski@users.noreply.github.com> Date: Fri, 16 Mar 2018 14:52:45 +0100 Subject: [PATCH 1/3] Update DefaultStock.php --- .../Model/ResourceModel/Indexer/Stock/DefaultStock.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php index 366cb1c3902a3..3050c5e6338f9 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php @@ -305,14 +305,17 @@ protected function _updateIndex($entityIds) 'stock_status' => (int)$row['status'], ]; if ($i % 1000 == 0) { + $this->deleteOldRecords(array_column($data, 'product_id')); $this->_updateIndexTable($data); $data = []; } } - $this->deleteOldRecords($entityIds); - $this->_updateIndexTable($data); - + if (is_array($data) && !empty($data)) { + $this->deleteOldRecords(array_column($data, 'product_id')); + $this->_updateIndexTable($data); + } + return $this; } From f98249e80f009110b4ed6852b07467905ea7ca37 Mon Sep 17 00:00:00 2001 From: m-milewski <32764961+m-milewski@users.noreply.github.com> Date: Fri, 6 Apr 2018 14:32:27 +0200 Subject: [PATCH 2/3] Update ActionTest.php --- .../testsuite/Magento/Catalog/Model/Product/ActionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ActionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ActionTest.php index 39905aeae10f5..b16149d134415 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ActionTest.php @@ -142,7 +142,7 @@ public function updateAttributesDataProvider() return [ [ 'status' => 2, - 'expected_count' => 0 + 'expected_count' => 1 ], [ 'status' => 1, From 7f22ea0cdb8e1f605b1e8025e070bffe29475521 Mon Sep 17 00:00:00 2001 From: m-milewski <32764961+m-milewski@users.noreply.github.com> Date: Fri, 20 Apr 2018 09:28:00 +0200 Subject: [PATCH 3/3] Update DefaultStock.php --- .../Model/ResourceModel/Indexer/Stock/DefaultStock.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php index 3050c5e6338f9..4e3e11e53ee5f 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php @@ -315,7 +315,6 @@ protected function _updateIndex($entityIds) $this->deleteOldRecords(array_column($data, 'product_id')); $this->_updateIndexTable($data); } - return $this; }