header

Magento 1.x Software Support Notice

For Magento Commerce 1, Magento is providing software support through June 2020. Depending on your Magento Commerce 1 version, software support may include both quality fixes and security patches. Please review our Magento Software Lifecycle Policy to see how your version of Magento Commerce 1 is supported.

For Magento Open Source 1.5 to 1.9, Magento is providing software security patches through June 2020 to ensure those sites remain secure and compliant. Visit our information page for more details about our software maintenance policy and other considerations for your business.

Product Custom Value Update

Module: Complex Product API

Resource: product_custom_option_value

Method:

Allows you to update the product custom option value.

Arguments:

Type Name Description
string sessionId Session ID
string
valueId Value ID
array data Array of catalogProductCustomOptionValueUpdateEntity
string storeId Store view ID or code (optional)

Return:

Type Description
boolean True if the custom option value is updated

The catalogProductCustomOptionValueUpdateEntity content is as follows:

Type Name Description
string title
Option value title
string
price
Option value price
string
price_type
Price type. Possible values are as follows: "fixed" or "percent"
string
sku
Custom option value row SKU
string
sort_order
Custom option value sort order

Faults:

Fault Code Fault Message
101 Option value with requested id does not exist.
103 Option with requested id does not exist.
104 Invalid option type.
107 Error while updating an option value. Details are in the error message.
108 Title 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);