0

我已经使用 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中的错误吗?

4

2 回答 2

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;


                }
            }
于 2013-12-24T17:13:00.030 回答
0

“xyz”需要进入关联实体的.value:

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

希望这可以帮助。

于 2012-10-30T20:03:09.327 回答