Magento API – Get Product Details

Magento API – Get Product Details « Magento Shipping Extensions

Magento API – Get Product Details

I was writing a little code snippet tonight to get the name and url for products in a particular category. Its quite simple to do with the Magento API, here is the code:

<?php
$soapUrl='http://www.testdomain.com/';
$apiUser='karen';
$apiPass='my_api_key';
$proxy = new SoapClient($soapUrl.'api/soap?wsdl');
$sessionId = $proxy->login($apiUser, $apiPass);
$productArr = $proxy->call($sessionId,
                   'catalog_category.assignedProducts', array('33'));
$extnDetails=array();
foreach ($productArr as $product) {
  $productListing = $proxy->call($sessionId, 'product.info', $product['sku']);
  $extnDetails[] = array (
         'name'=>$productListing['name'],
         'url' =>'http://www.testdomain.com/'.$productListing['url_path']
  );
}
print_r($extnDetails);
$proxy->endSession($sessionId);

The output is something like:

[name] => Nike Shoes      [url] => http://www.testdomain.com/nike_shoes.html )
[name] => Adidas Trainers [url] => http://www.testdomain.com/adidas_shoes.html )