Adding existing attribute to all attribute sets

前端 未结 6 1948
孤街浪徒
孤街浪徒 2021-02-06 05:53

I have an existing attribute for an embed code. I need to associate this attribute with 120+ existing attribute sets.

If I know the attribute set id, ho

6条回答
  •  眼角桃花
    2021-02-06 06:42

    The function Mage_Catalog_Model_Resource_Setup::addAttribute() can be used to update as well as add attributes. Another thing I find useful is if you specify a group with this function it is automatically assigned to all sets.

    $attributeCode = 'name'; // choose your attribute here
    $setup = Mage::getResourceSingleton('catalog/setup');
    $setup->addAttribute('catalog_product', $attributeCode, array(
        // no need to specify fields already used like 'label' or 'type'
        'group'      => 'General',
        'sort_order' => 10
    ));
    

提交回复
热议问题