When extracting a product attribute data using SOAP, the usual approach is to create a standard class and identify the common fields in the attributes property as shown below:

$proxy = new SoapClient('http://your.magento.domain/api/v2_soap/?wsdl');
$sessionId = $proxy->login('username', 'password!');
$product = new stdclass();
$product->attributes = array(
     'description',
     'short_description',
     'price',
     'custom_attribute_code'
);
$data = $proxy->catalogProductInfo($sessionId, $sku, null, $product);
var_dump($data);

The above var_dump() would show the values of requested fields except the custom_attribute_code. The reason for this is because a custom product attribute is available in additional_attributes property instead.

Get custom product attribute:

To get the value of custom_attribute_code, use the following code:

$proxy = new SoapClient('http://your.magento.domain/api/v2_soap/?wsdl');
$sessionId = $proxy->login('username', 'password!');
$product = new stdClass();
$product->additional_attributes = array('custom_attribute_code');
$data = $proxy->catalogProductInfo($sessionId, $sku, null, $product);

About the author

Richard Feraro is a Magento Enterprise Certified developer from Manila, Philippines with 14 years of solid open-source development experience using Linux, Apache, MySQL & PHP.

By Richard Feraro

Richard Feraro is a Magento Enterprise Certified developer from Manila, Philippines with 14 years of solid open-source development experience using Linux, Apache, MySQL & PHP.

Leave a Reply