0

Everyone, How can I set attributes to attribute set in Magento 2 programmatically

  • You are looking for an extension or you want to do it programatically? – Kalyan Chakravarthi V Feb 27 '18 at 6:36
  • programmatically – Shyam Hajare Feb 27 '18 at 6:39
0

The custom attribute gets assigned to all the attribute sets or you want to assign it to specific attribute set only.

Hope this will help you.

$attribute_set_name = 'your attribute set name';
$group_name = 'your attribute group';
$attribute_code = 'your attribute code';

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

//-------------- add attribute to set and group
$attribute_set_id=$setup->getAttributeSetId('catalog_product', $attribute_set_name);
$attribute_group_id=$setup->getAttributeGroupId('catalog_product', $attribute_set_id, $group_name);
$attribute_id=$setup->getAttributeId('catalog_product', $attribute_code);
$setup->addAttributeToSet($entityTypeId='catalog_product',$attribute_set_id, $attribute_group_id, $attribute_id);
  • 1
    I want to assign specific attributes set only .. – Shyam Hajare Feb 27 '18 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.