Magento 1.7 SOAP v2 Api - 使用其他属性创建产品

时间:2012-09-17 09:39:26

标签: asp.net magento soap attributes magento-1.7

我已经建立了一个Magento 1.7版的网上商店,我的下一个任务是使用v2 Soap api导入产品。到目前为止,除了一件事之外,一切似乎都有效:所创建产品的所有自定义属性都保持为空。其他一切都很好 - 名称,sku,价格,描述等。 我的脚本运行asp.net,所以我没有任何PHP代码,但我认为它看起来或多或少相似。以下是我使用的片段,其中属性已分配给产品:

dim create as new catalogProductCreateEntity
create.name = "Test"
create.price = "11.1100"
create.description = "test description"

dim additional(0) as associativeEntity
dim attribute as new associativeEntity
attribute.key = "manufacturer"
attribute.key = "xyz"
additional(0) = attribute

create.additional_attributes = additional

在这种情况下,简单的文本字段应该接收值“xyz”。 我在过去设置的其他Magento商店中使用了相同的程序,它运行得很好。唯一的区别是这些商店使用Magento 1.5版。 这可能是api中的错误吗?

2 个答案:

答案 0 :(得分:0)

“xyz”需要进入associativeEntity的.value:

dim additional(0) as associativeEntity
dim attribute as new associativeEntity
attribute.key = "manufacturer"
attribute.value = "xyz" 
additional(0) = attribute

希望这有帮助。

答案 1 :(得分:0)

我已经在C#中成功完成了这项工作,下面是代码

     private void getAdditionalAttributes()
            {
                string skuNumber="S00001";
                MagentoService mservice = new MagentoService();
                string sessionkey = "";
                try
                {
                    sessionkey = mservice.login("apiuser", "apipassword");


                }
                catch (Exception exp)
                {

                    //Error
                }

                try
                {
                    catalogProductRequestAttributes fetchattrib = new catalogProductRequestAttributes();
                    // it will only populate the attributes that you ask for
                    fetchattrib.attributes = new string[] { "name", "description", "short_description" };
// Additional Attribute
                    fetchattrib.additional_attributes = new string[] { "ismemo","color" };

    catalogProductReturnEntity prod =  MagentoConnectivity.magService.catalogProductInfo(sessionkey, skuNumber, "", fetchattrib, "sku");


                    foreach (var item in prod.additional_attributes)
                    {
                        MessageBox.Show("=> Key: " + item.key + "\t Attribute Value=" + item.value + "\n");
                    }

                }
                catch (Exception exp)
                {

                    MessageBox.Show("=> Exception in getting Additional Attributes \n" + exp.Message + "\n");
                    return;


                }
            }