Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Module: Complex Product API

Resource: product_custom_option_value

Method:
  • product_custom_option_value.add (SOAP V1)
  • catalogProductCustomOptionValueAdd (SOAP V2)

Allows you to add a new custom option value to a custom option. Note that the custom option value can be added only to the option with the Select Input Type.

Arguments:

TypeNameDescription
stringsessionIdSession ID
stringoptionIdOption ID
arraydataArray of catalogProductCustomOptionValueAdd
stringstoreStore view ID or code (optional)

Return:

TypeDescription
booleanTrue if the custom option value is added

The catalogProductCustomOptionValueAdd content is as follows:

TypeNameDescription
stringtitleCustom option value title
stringpriceCustom option value price
stringprice_typeType of the custom option value price. Can have one of the following values: “fixed” or “percent”
stringskuCustom option value row SKU
stringsort_orderCustom option value sort order

Faults:

Fault CodeFault Message
101Option value with requested id does not exist.
102Error while adding an option value. Details are in the error message.
104Invalid option type.

Examples

Request Example SOAP V1
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$productOptionId = 1;// Existing product option ID

// Add custom option value
$customOptionValue = array(
    "title" => "Some value text 1",
    "price" => 10.00,
    "price_type" => "fixed",
    "sku" => "custom_text_option_sku",
    "sort_order" => 0
);
$resultCustomOptionValueAdd = $proxy->call(
    $sessionId,
    "product_custom_option_value.add",
    array(
        $productOptionId,
        array($customOptionValue)
    )
);
Request Example SOAP V2
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

$sessionId = $proxy->login('apiUser', 'apiKey');

$result = $proxy->catalogProductCustomOptionValueAdd($sessionId, '10', array(array(
'title' => 'value',
'price' => '99.99',
'price_type' => 'fixed',
'sku' => 'sku',
'sort_order' => '1'
)));
var_dump($result);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey'));

$result = $proxy->catalogProductCustomOptionValueAdd((object)array('sessionId' => $sessionId->result, 'optionId' => '10', 'data' => array(array(
'title' => 'value',
'price' => '99.99',
'price_type' => 'fixed',
'sku' => 'sku',
'sort_order' => '1'
))));
var_dump($result->result);