Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
BulkZeroLegacyStockItem.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
18 {
22  private $resourceConnection;
23 
27  private $getProductIdsBySkus;
28 
33  public function __construct(
34  ResourceConnection $resourceConnection,
35  GetProductIdsBySkusInterface $getProductIdsBySkus
36  ) {
37  $this->resourceConnection = $resourceConnection;
38  $this->getProductIdsBySkus = $getProductIdsBySkus;
39  }
40 
46  public function execute(array $skus)
47  {
48  $productIds = array_values($this->getProductIdsBySkus->execute($skus));
49 
50  $connection = $this->resourceConnection->getConnection();
51  $connection->update(
52  $this->resourceConnection->getTableName('cataloginventory_stock_item'),
53  [
56  ],
57  [
59  'website_id = ?' => 0,
60  ]
61  );
62  }
63 }
__construct(ResourceConnection $resourceConnection, GetProductIdsBySkusInterface $getProductIdsBySkus)
foreach($websiteCodes as $websiteCode) $skus
$connection
Definition: bulk.php:13