Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
row_fixture_rollback.php
Go to the documentation of this file.
1 <?php
9 
10 $registry->unregister('isSecureArea');
11 $registry->register('isSecureArea', true);
12 
13 
14 $productSkuList = ['simple', '12345'];
15 foreach ($productSkuList as $sku) {
16  try {
18  ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
19  $product = $productRepository->get($sku, true);
20  if ($product->getId()) {
22  }
23  } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
24  //Product already removed
25  }
26 }
27 
30 $category->load(9);
31 if ($category->getId()) {
32  $category->delete();
33 }
34 
35 $registry->unregister('isSecureArea');
36 $registry->register('isSecureArea', false);