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

Module: Product Attributes API

Resource: product_attribute

Method:
  • product_attribute.update (SOAP V1)
  • catalogProductAttributeUpdate (SOAP V2)

Allows you to update the required attribute.

Arguments:

TypeNameDescription
stringsessionIdSession ID
stringattributeAttribute code or ID
arraydataArray of catalogProductAttributeEntityToUpdate

Returns:

TypeDescription
booleanTrue if the attribute is updated

The catalogProductAttributeEntityToUpdate content is as follows:

TypeNameDescription
stringscopeAttribute scope. Possible values are as follows: ‘store’, ‘website’, or ‘global’
stringdefault_valueAttribute default value
intis_uniqueDefines whether the attribute is unique
intis_requiredDefines whether the attribute is required
ArrayOfStringapply_toApply to. Empty for “Apply to all” or array of the following possible values: ‘simple’, ‘grouped’, ‘configurable’, ‘virtual’, ‘bundle’, ‘downloadable’, ‘giftcard’
intis_configurableDefines whether the attribute can be used for configurable products
intis_searchableDefines whether the attribute can be used in Quick Search
intis_visible_in_advanced_searchDefines whether the attribute can be used in Advanced Search
intis_comparableDefines whether the attribute can be compared on the frontend
intis_used_for_promo_rulesDefines whether the attribute can be used for promo rules
intis_visible_on_frontDefines whether the attribute can be visible on the frontend
intused_in_product_listingDefines whether the attribute can be used in product listing
associativeArrayadditional_fieldsArray of additional fields
arrayfrontend_labelArray of catalogProductAttributeFrontendLabel

The AdditionaFieldsEntity array of additional fields for the text type is as follows:

TypeNameDescription
stringfrontend_classInput Validation for Store Owner. Possible values: ‘validate-number’ (Decimal Number), ‘validate-digits’ (Integer Number), ‘validate-email’, ‘validate-url’, ‘validate-alpha’ (Letters), ‘validate-alphanum’ (Letters (a-z, A-Z), or Numbers (0-9))
booleanis_html_allowed_on_frontDefines whether the HTML tags are allowed on the frontend
booleanused_for_sort_byDefines whether it is used for sorting in product listing

The AdditionaFieldsEntity array of additional fields for the text area type is as follows:

TypeNameDescription
booleanis_wysiwyg_enabledEnable WYSIWYG flag
booleanis_html_allowed_on_frontDefines whether the HTML tags are allowed on the frontend

The AdditionaFieldsEntity array of additional fields for the date and boolean types is as follows:

TypeNameDescription
booleanused_for_sort_byDefines whether it is used for sorting in product listing

The AdditionaFieldsEntity array of additional fields for the multiselect type is as follows:

TypeNameDescription
booleanis_filterableDefines whether it used in layered navigation
booleanis_filterable_in_searchDefines whether it is used in search results layered navigation
integerpositionPosition

The AdditionaFieldsEntity array of additional fields for the select and price types is as follows:

TypeNameDescription
booleanis_filterableDefines whether it used in layered navigation
booleanis_filterable_in_searchDefines whether it is used in search results layered navigation
integerpositionPosition
booleanused_for_sort_byDefines whether it is used for sorting in product listing

The catalogProductAttributeFrontendLabel content is as follows:

TypeNameDescription
stringstore_idStore ID
stringlabelText label

Faults:

Fault CodeFault Message
101Requested attribute not found.
105Unable to save attribute.
107This attribute cannot be edited.

Examples

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

$attributeToUpdate = array(
    "scope" => "global",
    "is_unique" => 1,
    "is_required" => 1,
    "is_configurable" => 1,
    "is_searchable" => 1,
    "is_visible_in_advanced_search" => 0,
    "used_in_product_listing" => 0,
    "additional_fields" => array(
        "is_filterable" => 1,
        "is_filterable_in_search" => 0,
        "position" => 2,
        "used_for_sort_by" => 0
    ),
    "frontend_label" => array(
        array(
            "store_id" => 0,
            "label" => "A Test Attribute"
        )
    )
);

$result = $proxy->call(
    $sessionId,
    "product_attribute.update",
    array(
        $attributeToUpdate
    )
);
Request Example SOAP V2
<?php
//ini_set("soap.wsdl_cache_enabled", 0);

$client = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

//V2
$session = $client->login('apiUser', 'apiKey');

// V2 WS-I Mode
//$response = $client->login(array('username' => 'apiUser', 'apiKey' => 'apiKey'));
//$session = $response->result;


//v2
$attributeCode = "code1";
$data = array(
   "frontend_input" => "text",
   "scope" => "1",
   "default_value" => "1",
   "is_unique" => 0,
   "is_required" => 0,
   "apply_to" => array("simple"),
   "is_configurable" => 0,
   "is_searchable" => 0,
   "is_visible_in_advanced_search" => 0,
   "is_comparable" => 0,
   "is_used_for_promo_rules" => 0,
   "is_visible_on_front" => 0,
   "used_in_product_listing" => 0,
   "additional_fields" => array(),
   "frontend_label" => array(array("store_id" => "0", "label" => "some random label updated"))
  );

$orders = $client->catalogProductAttributeUpdate($session, $attributeCode, $data); 



//V2 WSI
//WSDL WSI Sample is not complete
//$result = $client->catalogProductAttributeCreate(array("sessionId" => $session, "data" => $data));
//$orders = $result->result->complexObjectArray;

echo 'Number of results: ' . count($orders) . '<br/>';
var_dump ($orders);
?>

Create the Magento file system owner