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.update (SOAP V1)
  • catalogProductCustomOptionValueUpdate (SOAP V2)

Allows you to update the product custom option value.

Arguments:

TypeNameDescription
stringsessionIdSession ID
stringvalueIdValue ID
arraydataArray of catalogProductCustomOptionValueUpdateEntity
stringstoreIdStore view ID or code (optional)

Return:

TypeDescription
booleanTrue if the custom option value is updated

The catalogProductCustomOptionValueUpdateEntity content is as follows:

TypeNameDescription
stringtitleOption value title
stringpriceOption value price
stringprice_typePrice type. Possible values are as follows: “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.
103Option with requested id does not exist.
104Invalid option type.
107Error while updating an option value. Details are in the error message.
108Title field is required.

Examples

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

$productOptionId = 1;// Existing option ID

// Get last value from option values list
$optionValues = $proxy->call($sessionId, "product_custom_option_value.list", array($productOptionId));
$optionValue = reset($optionValues);
$valueId = $optionValue['value_id'];
// Update custom option value
$customOptionValue = array(
    "title" => "new title",
    "price" => 12.00,
    "price_type" => "percent",
    "sku" => "custom_text_option_2",
    "sort_order" => 2
);
$resultCustomOptionValueUpdate = $proxy->call(
    $sessionId,
    "product_custom_option_value.update",
    array(
         $valueId,
         $customOptionValue
    )
);
Request Example SOAP V2
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

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

$result = $proxy->catalogProductCustomOptionValueUpdate($sessionId, '2', array(
'title' => 'value',
'price' => '20',
'price_type' => 'fixed',
'sku' => 'sku'
));

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->catalogProductCustomOptionValueUpdate((object)array('sessionId' => $sessionId->result, 'valueId' => '2', 'data' => ((object)array(
'title' => 'value',
'sku' => 'sku',
'price' => '199',
'price_type' => 'percent'
))));

var_dump($result->result);