Magento Forum

   
Using SOAP API to retrieve additional attributes of products
 
m4zlg
Jr. Member
 
Total Posts:  29
Joined:  2011-05-10
 

Hi
I’m currently getting started with the Magento SOAP API and my goal is to compare different product attributes to other values from a database and update certain products if necessary. So far everything seems to work fine except for one thing:

I can not access the “additional_attributes” variable from a “catalogProductInfo” object. I managed to read out the price, the id and the name aswell from a bunch of different products but when trying to access “additional_attributes” it always returns Null
When I try to update a product (eg change the price or name) I create an associative array containing everything that needs to be changed and assign it to “additional_attributes” - and it works, so somehow there must be a way to get these information back from a product…

Am I maybe approaching this in the wrong way?

Any help will be appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ambaum2
Jr. Member
 
Total Posts:  3
Joined:  2010-10-05
 

I had this same problem and couldn’t find an answer specifically for the catalogProductInfo anywhere so I’ll post here. To get custom attributes in the response you must add each attribute in your request under “additional_attributes” which is under the “attributes” section Make it like this for the raw soap request:

<attributes xsi:type="urn:catalogProductRequestAttributes" xs:type="type:catalogProductRequestAttributes" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">
            <
attributes xsi:type="urn:ArrayOfString" soapenc:arrayType="xsd:string[]" xs:type="type:string">
            </
attributes>
            <
additional_attributes xsi:type="urn:ArrayOfString" soapenc:arrayType="xsd:string[]" xs:type="type:string">
                <
item xsi:type="xsd:string">myfield</item>
                <
item xsi:type="xsd:string">myfield2</item>
            </
additional_attributes>
         </
attributes>

In your code you would do the above with ‘additional_attributes as an array like this:

'additional_attributes' => array
            (
            array(
'key' => 'myfield''value' => 'field1'),
            array(
'key' => 'myfield2''value' => 'field2')
            )

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top