I've been working with the API for Magento in recent weeks and I had a bit of a struggle explaining to the V2 API which attributes of a product I wanted to retrieve. Actually I had issues talking to the V2 API at all, but that's a different post so I'll skate over those for now. Instead I thought I'd share (or rather, record for the next time I have the same problem!) how to specify which attributes about a product to retrieve.
It actually wasn't complicated but without V2 API documentation, it wasn't at all clear what to feed in to get the result I was looking for. It turns out you can just pass an array of desired attributes, shown here with the info method from the product_catalog:
// 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'); $list = $client->catalogProductInfo($session, <sku>, NULL, $attributes);
There were two tricks - one was realising that I could pass that final (undocumented) argument, and the other was understanding how to format that. Hopefully anyone doing battle with the same thing will find this post and get over this little challenge much faster than I did :)