1

I am using SOAP v1 of the Magento API, I am trying to add an option to an attribute.

My Code:

$attributeCode = "feltColor";
$optionToAdd = array(
    "Label" => array(
        array(
            "store_id" => 1,
            "value" => "Green"
        )
    ),
    "order" => 0,
    "is_default" => 0
);

But I keep getting the following error:

Fatal error: Uncaught SoapFault exception: [108] Default option value is not defined

Can't get it to work...any suggestions?

Mufaddal
  • 5,398
  • 7
  • 42
  • 57
kmaas
  • 11
  • 3

1 Answers1

0

You need to specify a label for store_id = 0 (instead of or in addition to defining one for store_id = 1).

This is from the docs for product_attribute.create, but also holds true for product_attribute.addOption:

Notes: The "label" value for the "store_id" value set to 0 must be specified. An attribute cannot be created without specifying the label for store_id=0.

If you define a label for store_id = 0, that is the default, so you don't need to define it for other store views unless you want to override the default:

$attributeCode = "feltColor";
$optionToAdd = array(
    "Label" => array(
        array(
            "store_id" => 0,
            "value" => "Green"
        )
    ),
    "order" => 0,
    "is_default" => 0
);
sina
  • 1,091
  • 1
  • 8
  • 6