Ez.Newsletter.MagentoApi product_attribute.addOption

134 Views Asked by At

I have found the Ez.Newsletter.MagentoApi C# project on the internet. I think its a great tool to Test the Magento SOAP API.

But after struggling with some code for WEEKS now I decided to ask a question.

In the project, there is no sample for the AddOption in the ProductAttributeOption (Link).

This is the Public Method I have added to the Api solution:

public static bool addOption(string apiUrl, string sessionId, object[] args)
    {
        IProductAttributeOption prox = (IProductAttributeOption)XmlRpcProxyGen.Create(typeof(IProductAttributeOption));
        prox.Url = apiUrl;
        return prox.addOption(sessionId, _catalog_product_attribute_add_option, args);
    }

And this is the code for adding the Option:

bool OptionAdded = ProductAttributeOption.addOption(apiUrl, sessionId, new object[] {
             attributeCode,
             new object[] {
                 new object[] {
                     "0", //store_id
                     "New Label Name" //value
                 },
                 "0", //orderid
                 "0"  //is_default
             }
         });

But the error of the server is like:

An unhandled exception of type 'CookComputing.XmlRpc.XmlRpcFaultException' occurred in CookComputing.XmlRpcV2.dll Additional information: Server returned a fault exception: [108] Default option value is not defined

1

There are 1 best solutions below

0
On

I just came across this issue myself. We use Python with Magento1.9 Xml-RPC

You're currently formatting very similar as I did initially:

    {'label': {'store_id': '0','value':'Purple'}, 'is_default': 0, 'order': 0}

After some playing around, wrapping the label value in another list did the trick:

    {'label': [{'store_id': '0','value':'Purple'}], 'is_default': 0, 'order': 0}

This is my 5cents. Hope it helps you forward.