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

Module: Complex Product API

Resource: product_custom_option

Method:
  • product_custom_option.update (SOAP V1)
  • catalogProductCustomOptionUpdate (SOAP V2)

Allows you to update the required product custom option.

Arguments:

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

Return:

TypeDescription
boolean\intTrue (1) if the custom option is updated

The catalogProductCustomOptionToUpdate content is as follows:

TypeNameDescription
stringtitleTitle of the custom option to be updated
stringtypeCustom option type
stringsort_orderCustom option sort order
intis_requireDefines whether the custom option is required
arrayadditional_fieldsArray of catalogProductCustomOptionAdditionalFields

The catalogProductCustomOptionAdditionalFields content is as follows:

TypeNameDescription
stringtitleCustom option title
stringpriceCustom option price
stringprice_typePrice type. Possible values are as follows: “fixed” or “percent”
stringskuCustom option SKU
stringmax_charactersMaximum number of characters for the customer input on the frontend (optional)
stringsort_orderCustom option sort order
stringfile_extensionList of file extensions allowed to upload by the user on the frontend (optional; for the File input type)
stringimage_size_xWidth limit for uploaded images (optional; for the File input type)
stringimage_size_yHeight limit for uploaded images (optional; for the File input type)
stringvalue_idValue ID

Faults:

Fault CodeFault Message
101Product with requested id does not exist.
102Provided data is invalid.
103Error while saving an option. Details are in the error message.
104Store with requested code/id does not exist.
105Option with requested id does not exist.
106Invalid option type provided. Call ‘types’ to get list of allowed option types.

Examples

Request Example SOAP V1
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$selectOptionId = 1379;
$selectOptionValueId = 794;
$textOptionId = 1380;
$fileOptionId = 1381;

// Update custom option of Text Field type
$customTextFieldOption = array(
    "title" => "Custom Text Field Option Title Updated",
    "type" => "field",
    "is_require" => 1,
    "sort_order" => 20,
    "additional_fields" => array(
        array(
            "price" => 13.00,
            "price_type" => "fixed",
            "sku" => "custom_text_option_sku_updated",
            "max_characters" => 127
        )
    )
);
$resultCustomTextFieldOptionUpdate = $proxy->call(
    $sessionId,
    "product_custom_option.update",
    array(
         $textOptionId,
         $customTextFieldOption
    )
);

// Update custom option of File type
$customFileOption = array(
    "title" => "Custom File Option Title Updated",
    "additional_fields" => array(
        array(
            "image_size_x" => 800,
            "image_size_y" => 999
        )
    )
);
$resultCustomFileOptionUpdate = $proxy->call(
    $sessionId,
    "product_custom_option.update",
    array(
         $fileOptionId,
         $customFileOption
    )
);


// Update custom option of Dropdown type
$customDropdownOption = array(
    "title" => "Custom Dropdown Option Title Updated to Multiselect",
    "type" => "multiple",
    "additional_fields" => array(
        array(
            "value_id" => $selectOptionValueId,
            "price" => 14.00,
            "price_type" => 'percent',
            "sku" => "custom_select_option_sku_1 updated",
            "sort_order" => 26
        )
    )
);
$resultCustomDropdownOptionUpdate = $proxy->call(
    $sessionId,
    "product_custom_option.update",
    array(
         $selectOptionId,
         $customDropdownOption
    )
);
Request Example SOAP V2
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

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

$result = $proxy->catalogProductCustomOptionUpdate($sessionId, '1', array(
'title' => 'title_updated',
'is_require' => 0,
'sort_order' => '2'
));
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->catalogProductCustomOptionUpdate((object)array('sessionId' => $sessionId->result, 'optionId' => '1', 'data' => ((object)array(
'title' => 'title_updated',
'is_require' => 0,
'sort_order' => '2'
))));
var_dump($result->result);