Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
multiple_products_with_non_saleable_product_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
12 
13 $registry->unregister('isSecureArea');
14 $registry->register('isSecureArea', true);
15 
17 $productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
18 
19 foreach (['simple_saleable', 'simple_not_saleable'] 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);