Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
categories_no_products_rollback.php
Go to the documentation of this file.
1 <?php
9 $registry = $objectManager->get(\Magento\Framework\Registry::class);
10 
11 $registry->unregister('isSecureArea');
12 $registry->register('isSecureArea', true);
13 
14 //Remove categories
16 $collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
18  ->addAttributeToFilter('level', 2)
19  ->load()
20  ->delete();
21 
22 $registry->unregister('isSecureArea');
23 $registry->register('isSecureArea', false);