Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
search_weight_products_rollback.php
Go to the documentation of this file.
1 <?php
11 $registry = $objectManager->get(\Magento\Framework\Registry::class);
12 
13 $registry->unregister('isSecureArea');
14 $registry->register('isSecureArea', true);
15 
17 $collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
18 $collection->addAttributeToSelect('id')->load();
19 if ($collection->count() > 0) {
20  $collection->delete();
21 }
22 
23 $registry->unregister('isSecureArea');
24 $registry->register('isSecureArea', false);
25 
28  \Magento\Catalog\Api\ProductAttributeRepositoryInterface::class
29 );
30 
32 $nameAttribute->setSearchWeight(5);
34 
36 $descriptionAttribute->setSearchWeight(1);