代码之家  ›  专栏  ›  技术社区  ›  Capitaine

如何通过magento api以编程方式将属性分配给特定的属性集?

  •  11
  • Capitaine  · 技术社区  · 15 年前

    标题。 我没有找到相关的解决方案/问题。我只是想知道如何通过API为某个属性集的产品分配一个新的属性。

    2 回复  |  直到 14 年前
        1
  •  29
  •   Anda B    15 年前

    像这样:

    $attribute_set_name = 'your attribute set name here';
    $group_name = 'your attribute group here';
    $attribute_code = 'your attribute code here';
    
    $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);
    
        2
  •  0
  •   Jonathan Day    15 年前

    我不确定你会怎么做,但我可以想象 Mage_Eav_Model_Mysql4_Entity_Attribute_Collection Mage_Eav_Model_Entity_Attribute_Group 会把你带到正确的方向…

    推荐文章