Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
stocks_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
12 
14 $stockRepository = Bootstrap::getObjectManager()->get(StockRepositoryInterface::class);
15 foreach ([10, 20, 30] as $stockId) {
16  try {
17  $stockRepository->deleteById($stockId);
18  } catch (NoSuchEntityException $e) {
19  //Stock already removed
20  }
21 }
22 
23 $removeIndexData = Bootstrap::getObjectManager()->get(RemoveIndexData::class);
24 $removeIndexData->execute([10, 20, 30]);
$stockRepository
foreach([10, 20, 30] as $stockId) $removeIndexData