Skip to content

Commit ec882e7

Browse files
committed
MAGETWO-58134: [GitHub] Products became “out of stock” after update from 2.0.7 to 2.1.0 #5222
1 parent 512ad27 commit ec882e7

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
*/
66
namespace Magento\CatalogInventory\Setup;
77

8-
use Magento\CatalogInventory\Model\Configuration;
9-
use Magento\CatalogInventory\Model\Indexer\Stock\Processor;
8+
use Magento\CatalogInventory\Api\StockConfigurationInterface;
9+
use Magento\Framework\Indexer\AbstractProcessor;
1010
use Magento\Framework\Setup\UpgradeDataInterface;
1111
use Magento\Framework\Setup\ModuleContextInterface;
1212
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Store\Model\StoreManagerInterface;
1314

1415
/**
1516
* Upgrade Data script
@@ -18,25 +19,33 @@
1819
class UpgradeData implements UpgradeDataInterface
1920
{
2021
/**
21-
* @var Configuration
22+
* @var StockConfigurationInterface
2223
*/
2324
private $configuration;
2425

2526
/**
26-
* @var Processor
27+
* @var AbstractProcessor
2728
*/
28-
private $stockIndexerProcessor;
29+
private $indexerProcessor;
2930

3031
/**
31-
* @param Configuration $configuration
32-
* @param Processor $stockIndexerProcessor
32+
* @var StoreManagerInterface
33+
*/
34+
private $storeManager;
35+
36+
/**
37+
* @param StockConfigurationInterface $configuration
38+
* @param StoreManagerInterface $storeManager
39+
* @param AbstractProcessor $indexerProcessor
3340
*/
3441
public function __construct(
35-
Configuration $configuration,
36-
Processor $stockIndexerProcessor
42+
StockConfigurationInterface $configuration,
43+
StoreManagerInterface $storeManager,
44+
AbstractProcessor $indexerProcessor
3745
) {
3846
$this->configuration = $configuration;
39-
$this->stockIndexerProcessor = $stockIndexerProcessor;
47+
$this->storeManager = $storeManager;
48+
$this->indexerProcessor = $indexerProcessor;
4049
}
4150

4251
/**
@@ -60,8 +69,9 @@ private function upgradeCatalogInventoryStockItem($setup)
6069
{
6170
$setup->getConnection()->update(
6271
$setup->getTable('cataloginventory_stock_item'),
63-
['website_id' => $this->configuration->getDefaultScopeId()]
72+
['website_id' => $this->configuration->getDefaultScopeId()],
73+
['website_id = ?' => $this->storeManager->getWebsite()->getId()]
6474
);
65-
$this->stockIndexerProcessor->getIndexer()->reindexAll();
75+
$this->indexerProcessor->getIndexer()->reindexAll();
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)