Magento 1: How to assign an attribute to all products? -


i creating attribute , assigning attribute sets. have found new attribute not associated products until mass update on products.

is there way automate process?

i using following code create attribute , assign attribute sets

<?php $installer = $this; $installer->startsetup();  $attr = mage::getresourcemodel('catalog/eav_attribute')->loadbycode('catalog_product', 'new_boolean_attribute'); if (!$attr->getid()) {     $attribute = $installer->addattribute('catalog_product', 'new_boolean_attribute', array(         'type'              => 'int',         'input'             => 'boolean',         'backend'           => '',         'frontend'          => '',         'label'             => 'exclude product rules',         'source'            => 'eav/entity_attribute_source_table',         'global'            => mage_catalog_model_resource_eav_attribute::scope_global,         'required'          => false,         'user_defined'      => true,         'unique'            => false,         'default'           => '0',     )); }  $attributegroupname = 'general';  $entitytypeid = $installer->getentitytypeid('catalog_product');  $sets = mage::getmodel('eav/entity_attribute_set')->getresourcecollection();  foreach($sets $set) {     //do attribute sets     $attributesetid = $set->getdata('attribute_set_id');     $installer->addattributegroup($entitytypeid, $attributesetid, $attributegroupname, 3);      $attributegroupid = $installer->getattributegroupid($entitytypeid, $attributesetid, $attributegroupname);     $attributeid = $installer->getattributeid($entitytypeid, 'new_boolean_attribute');     $installer->addattributetogroup($entitytypeid, $attributesetid, $attributegroupid, $attributeid, null); }  $installer->endsetup(); 

try re-indexing magneto admin panel.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -