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