Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
indexer_rollback.php
Go to the documentation of this file.
1 <?php
9 
11 $registry = $objectManager->get(\Magento\Framework\Registry::class);
12 $registry->unregister('isSecureArea');
13 $registry->register('isSecureArea', true);
14 
16 $collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
17 $collection->addAttributeToSelect('id')->load();
18 if ($collection->count() > 0) {
19  $collection->delete();
20 }
21 
23 $store = $objectManager->create(\Magento\Store\Model\Store::class);
24 $storeCode = 'secondary';
25 $store->load($storeCode);
26 if ($store->getId()) {
27  $store->delete();
28 }
29 
30 $registry->unregister('isSecureArea');
31 $registry->register('isSecureArea', false);
$storeCode
$collection
$objectManager