2012-09-17 55 views
0

我已經建立了一個Magento 1.7版的網上商店,我的下一個任務是使用v2 Soap api導入產品。到目前爲止,除了一件事外,一切似乎都奏效:所創建產品的所有自定義屬性都保持爲空。其他一切正常 - 名稱,SKU,價格,描述等等。 我的腳本使用asp.net運行,所以我沒有任何PHP代碼,但我認爲它看起來或多或少相似。這裏就是屬性分配給一個產品,我用一個片段:Magento 1.7 SOAP v2 Api - 創建具有附加屬性的產品

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中的錯誤嗎?

回答

0

「XYZ」 需要進入.value的的associativeEntity的:

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

希望這有助於。

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; 


       } 
      } 
相關問題