Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
filterable_attributes_rollback.php
Go to the documentation of this file.
1 <?php
12 
13 $registry = Bootstrap::getObjectManager()->get(Registry::class);
14 $registry->unregister('isSecureArea');
15 $registry->register('isSecureArea', true);
17 $productCollection = Bootstrap::getObjectManager()
18  ->create(Product::class)
19  ->getCollection();
20 foreach ($productCollection as $product) {
21  $product->delete();
22 }
24 $attribute = Bootstrap::getObjectManager()->create(
25  Attribute::class
26 );
28 $installer = Bootstrap::getObjectManager()->create(CategorySetup::class);
29 foreach (range(1, 2) as $index) {
30  $attribute->loadByCode($installer->getEntityTypeId('catalog_product'), 'select_attribute_' . $index);
31  if ($attribute->getId()) {
32  $attribute->delete();
33  }
34 }
35 $registry->unregister('isSecureArea');
36 $registry->register('isSecureArea', false);
$index
Definition: list.phtml:44