Ejemplo n.º 1
0
 /**
  * Update some categories attributes to have them indexed into ES.
  * Basically :
  *  - Name (indexable and searchable
  *  - Description (indexable and searchable)
  *  - Url Path (indexable)
  */
 private function updateCategorySearchableAttributes()
 {
     $setup = $this->eavSetup->getSetup();
     $connection = $setup->getConnection();
     $table = $setup->getTable('catalog_eav_attribute');
     // Set Name and description indexable and searchable.
     $attributeIds = [$this->eavSetup->getAttributeId(\Magento\Catalog\Model\Category::ENTITY, 'name'), $this->eavSetup->getAttributeId(\Magento\Catalog\Model\Category::ENTITY, 'description')];
     foreach (['is_searchable', 'is_used_in_spellcheck'] as $configField) {
         foreach ($attributeIds as $attributeId) {
             $connection->update($table, [$configField => 1], $connection->quoteInto('attribute_id = ?', $attributeId));
         }
     }
     // Set url_path indexable.
     $urlPathAttributeId = $this->eavSetup->getAttributeId(\Magento\Catalog\Model\Category::ENTITY, 'url_path');
     $connection->update($table, ['is_searchable' => 1], $connection->quoteInto('attribute_id = ?', $urlPathAttributeId));
 }
Ejemplo n.º 2
0
 /**
  * Update default values for the name field of category and product entities.
  *
  * @return void
  */
 private function updateDefaultValuesForNameAttributes()
 {
     $setup = $this->eavSetup->getSetup();
     $connection = $setup->getConnection();
     $table = $setup->getTable('catalog_eav_attribute');
     $attributeIds = [$this->eavSetup->getAttributeId(\Magento\Catalog\Model\Product::ENTITY, 'name'), $this->eavSetup->getAttributeId(\Magento\Catalog\Model\Category::ENTITY, 'name')];
     foreach (['is_used_in_spellcheck', 'is_used_in_autocomplete'] as $configField) {
         foreach ($attributeIds as $attributeId) {
             $connection->update($table, [$configField => 1], $connection->quoteInto('attribute_id = ?', $attributeId));
         }
     }
 }