comme intitulé. Je n'ai trouvé aucune solution ou question connexe. Je me demande simplement comment je peux attribuer un nouvel attribut à un produit d'un certain ensemble d'attributs via l'API.Comment un attribut peut-il être affecté à un ensemble d'attributs spécifique par programmation via l'API Magento?
11
A
Répondre
29
Quelque chose comme ceci:
$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);
0
Je ne suis pas certain exactement comment vous le faire, mais j'imagine que l'utilisation Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
et Mage_Eav_Model_Entity_Attribute_Group
vous obtiendrez dans la bonne direction ...
Que Dieu vous bénisse, j'ai travaillé 8 heures pour résoudre ce problème: D – zuzuleinen