Magento – Magento SOAP v2 attributes parameter for product

apimagento-1.9soapsoap-api-v2

According to the API Docs, one can specify an array of attributes as a parameter when retrieving a product. What is the purpose in that?

Best Answer

The parameter attributes (it's a Array of catalogProductRequestAttributes) It is used to define which attributes about a product to retrieve in request response.

Note that the additional attributes will be returned in through the associative array named additional_attributes in catalogProductReturnEntity.

Example to retrive just product title, description, short description and price attributes.

// connect to soap server
$client = new SoapClient('http://magentoinstall.local/api/v2_soap?wsdl=1');

// log in
$session = $client->login('user', 'pass');

// product info
$attributes = new stdclass();
$attributes->attributes = array('product_title', 'description', 'short_description', 'price');
$productInfo = $client->catalogProductInfo($session, 'sku', NULL, $attributes);

Doing an analogy with Magento Collections, this has an effect similar to addAttributeToSelect() method.

Related Topic