Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
indexer_catalog_products_rollback.php
Go to the documentation of this file.
1 <?php
9 
11 $registry = $objectManager->get(\Magento\Framework\Registry::class);
12 
13 $registry->unregister('isSecureArea');
14 $registry->register('isSecureArea', true);
15 
17 $productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
18 
19 foreach (['simple 01', 'simple 02', 'simple 03'] as $sku) {
20  try {
21  $product = $productRepository->get($sku, false, null, true);
23  } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
24  //Product already removed
25  }
26 }
27 
28 $registry->unregister('isSecureArea');
29 $registry->register('isSecureArea', false);