Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
products_for_search_rollback.php
Go to the documentation of this file.
1 <?php
11 
12 Bootstrap::getInstance()->getInstance()->reinitialize();
13 
15 $registry = Bootstrap::getObjectManager()->get(Registry::class);
16 
17 $registry->unregister('isSecureArea');
18 $registry->register('isSecureArea', true);
19 
21 $productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class);
22 
23 $productSkus = ['search_product_1', 'search_product_2', 'search_product_3', 'search_product_4', 'search_product_5'];
24 foreach ($productSkus as $sku) {
25  try {
26  $product = $productRepository->get($sku, false, null, true);
28  } catch (NoSuchEntityException $e) {
29  }
30 }
31 
32 include_once 'category_rollback.php';
33 
34 $registry->unregister('isSecureArea');
35 $registry->register('isSecureArea', false);