5
5
*/
6
6
namespace Magento \CatalogInventory \Setup ;
7
7
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 ;
10
10
use Magento \Framework \Setup \UpgradeDataInterface ;
11
11
use Magento \Framework \Setup \ModuleContextInterface ;
12
12
use Magento \Framework \Setup \ModuleDataSetupInterface ;
13
+ use Magento \Store \Model \StoreManagerInterface ;
13
14
14
15
/**
15
16
* Upgrade Data script
18
19
class UpgradeData implements UpgradeDataInterface
19
20
{
20
21
/**
21
- * @var Configuration
22
+ * @var StockConfigurationInterface
22
23
*/
23
24
private $ configuration ;
24
25
25
26
/**
26
- * @var Processor
27
+ * @var AbstractProcessor
27
28
*/
28
- private $ stockIndexerProcessor ;
29
+ private $ indexerProcessor ;
29
30
30
31
/**
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
33
40
*/
34
41
public function __construct (
35
- Configuration $ configuration ,
36
- Processor $ stockIndexerProcessor
42
+ StockConfigurationInterface $ configuration ,
43
+ StoreManagerInterface $ storeManager ,
44
+ AbstractProcessor $ indexerProcessor
37
45
) {
38
46
$ this ->configuration = $ configuration ;
39
- $ this ->stockIndexerProcessor = $ stockIndexerProcessor ;
47
+ $ this ->storeManager = $ storeManager ;
48
+ $ this ->indexerProcessor = $ indexerProcessor ;
40
49
}
41
50
42
51
/**
@@ -60,8 +69,9 @@ private function upgradeCatalogInventoryStockItem($setup)
60
69
{
61
70
$ setup ->getConnection ()->update (
62
71
$ setup ->getTable ('cataloginventory_stock_item ' ),
63
- ['website_id ' => $ this ->configuration ->getDefaultScopeId ()]
72
+ ['website_id ' => $ this ->configuration ->getDefaultScopeId ()],
73
+ ['website_id = ? ' => $ this ->storeManager ->getWebsite ()->getId ()]
64
74
);
65
- $ this ->stockIndexerProcessor ->getIndexer ()->reindexAll ();
75
+ $ this ->indexerProcessor ->getIndexer ()->reindexAll ();
66
76
}
67
77
}
0 commit comments