Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
reindex_inventory_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
13 
15 $stockRepository = Bootstrap::getObjectManager()->get(StockRepositoryInterface::class);
17 $removeIndexData = Bootstrap::getObjectManager()->get(RemoveIndexData::class);
18 
19 $stockIds = [];
20 foreach ($stockRepository->getList()->getItems() as $stock) {
21  $stockIds[$stock->getStockId()] = $stock->getStockId();
22 }
23 
25 $moduleManager = Bootstrap::getObjectManager()->get(Manager::class);
26 // soft dependency in tests because we don't have possibility replace fixture from different modules
27 if ($moduleManager->isEnabled('Magento_InventoryCatalog')) {
29  $defaultStockProvider = Bootstrap::getObjectManager()->get(DefaultStockProviderInterface::class);
30  unset($stockIds[$defaultStockProvider->getId()]);
31 }
32 
33 $removeIndexData->execute(array_values($stockIds));
$stock