Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateStockItemsWebsite.php
Go to the documentation of this file.
1 <?php
8 
14 
20 {
24  private $moduleDataSetup;
25 
29  private $stockConfiguration;
30 
34  private $storeManager;
35 
39  private $indexerProcessor;
40 
48  public function __construct(
49  ModuleDataSetupInterface $moduleDataSetup,
50  \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
51  \Magento\Store\Model\StoreManagerInterface $storeManager,
52  Processor $indexerProcessor
53  ) {
54  $this->moduleDataSetup = $moduleDataSetup;
55  $this->stockConfiguration = $stockConfiguration;
56  $this->storeManager = $storeManager;
57  $this->indexerProcessor = $indexerProcessor;
58  }
59 
63  public function apply()
64  {
65  $this->moduleDataSetup->getConnection()->update(
66  $this->moduleDataSetup->getTable('cataloginventory_stock_item'),
67  ['website_id' => $this->stockConfiguration->getDefaultScopeId()],
68  ['website_id = ?' => $this->storeManager->getWebsite()->getId()]
69  );
70  $this->indexerProcessor->getIndexer()->invalidate();
71  }
72 
76  public static function getDependencies()
77  {
78  return [
79  CreateDefaultStock::class,
80  ];
81  }
82 
86  public static function getVersion()
87  {
88  return '2.2.0';
89  }
90 
94  public function getAliases()
95  {
96  return [];
97  }
98 }
__construct(ModuleDataSetupInterface $moduleDataSetup, \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration, \Magento\Store\Model\StoreManagerInterface $storeManager, Processor $indexerProcessor)
$storeManager