Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
products_with_websites_and_stores_rollback.php
Go to the documentation of this file.
1 <?php
7 require __DIR__ . '/../../Store/_files/second_website_with_two_stores_rollback.php';
8 
10 $productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
11 
13 $registry = $objectManager->get(\Magento\Framework\Registry::class);
14 
15 $registry->unregister('isSecureArea');
16 $registry->register('isSecureArea', true);
17 
19 $productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
20 
21 try {
22  foreach (['simple-2', 'simple-1'] as $sku) {
23  $product = $productRepository->get($sku, false, null, true);
25  }
26 } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
27  //Product already removed
28 }
29 
30 $registry->unregister('isSecureArea');
31 $registry->register('isSecureArea', false);
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60