Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
product_bundle_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
12 
13 $objectManager = Bootstrap::getObjectManager();
14 
16 $registry = $objectManager->get(Registry::class);
17 
18 $registry->unregister('isSecureArea');
19 $registry->register('isSecureArea', true);
20 
22 $productRepository = Bootstrap::getObjectManager()
23  ->get(ProductRepositoryInterface::class);
24 
25 foreach (['simple_10', 'bundle'] as $sku) {
26  try {
27  $product = $productRepository->get($sku, false, null, true);
29  } catch (NoSuchEntityException $e) {
30  //Product already removed
31  }
32 }
33 $registry->unregister('isSecureArea');
34 $registry->register('isSecureArea', false);