Skip to content

Commit a92bbd3

Browse files
committed
MAGETWO-58134: [GitHub] Products became “out of stock” after update from 2.0.7 to 2.1.0 #5222
- set cataloginventory_stock index as invalid
1 parent 9da5634 commit a92bbd3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/code/Magento/CatalogInventory/Setup/UpgradeData.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\CatalogInventory\Setup;
77

88
use Magento\CatalogInventory\Api\StockConfigurationInterface;
9+
use Magento\Framework\Indexer\AbstractProcessor;
910
use Magento\Framework\Setup\UpgradeDataInterface;
1011
use Magento\Framework\Setup\ModuleContextInterface;
1112
use Magento\Framework\Setup\ModuleDataSetupInterface;
@@ -22,6 +23,11 @@ class UpgradeData implements UpgradeDataInterface
2223
*/
2324
private $configuration;
2425

26+
/**
27+
* @var AbstractProcessor
28+
*/
29+
private $indexerProcessor;
30+
2531
/**
2632
* @var StoreManagerInterface
2733
*/
@@ -30,13 +36,16 @@ class UpgradeData implements UpgradeDataInterface
3036
/**
3137
* @param StockConfigurationInterface $configuration
3238
* @param StoreManagerInterface $storeManager
39+
* @param AbstractProcessor $indexerProcessor
3340
*/
3441
public function __construct(
3542
StockConfigurationInterface $configuration,
36-
StoreManagerInterface $storeManager
43+
StoreManagerInterface $storeManager,
44+
AbstractProcessor $indexerProcessor
3745
) {
3846
$this->configuration = $configuration;
3947
$this->storeManager = $storeManager;
48+
$this->indexerProcessor = $indexerProcessor;
4049
}
4150

4251
/**
@@ -63,5 +72,6 @@ private function upgradeCatalogInventoryStockItem($setup)
6372
['website_id' => $this->configuration->getDefaultScopeId()],
6473
['website_id = ?' => $this->storeManager->getWebsite()->getId()]
6574
);
75+
$this->indexerProcessor->getIndexer()->invalidate();
6676
}
6777
}

app/code/Magento/CatalogInventory/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,9 @@
7474
<type name="Magento\Catalog\Api\ProductRepositoryInterface">
7575
<plugin name="catalogInventoryAroundSave" sortOrder="20" type="Magento\CatalogInventory\Model\Plugin\AroundProductRepositorySave"/>
7676
</type>
77+
<type name="Magento\CatalogInventory\Setup\UpgradeData">
78+
<arguments>
79+
<argument name="indexerProcessor" xsi:type="object">Magento\CatalogInventory\Model\Indexer\Stock\Processor</argument>
80+
</arguments>
81+
</type>
7782
</config>

0 commit comments

Comments
 (0)