Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
category_duplicates_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
12 
14 $registry = $objectManager->get(\Magento\Framework\Registry::class);
15 
16 $registry->unregister('isSecureArea');
17 $registry->register('isSecureArea', true);
18 
20 $categoryCollection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
22  ->addAttributeToFilter('level', 2)
23  ->load()
24  ->delete();
25 
27 $productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
28 try {
29  $product = $productRepository->get('simple3', false, null, true);
31 } catch (NoSuchEntityException $e) {
32 }
33 
34 $registry->unregister('isSecureArea');
35 $registry->register('isSecureArea', false);