I was having some issues yesterday with this, but I already managed to solve it using only API calls, as I was using both API and Magento Core.
This is my actual code:
$proxy = new SoapClient($this->_api_url); // TODO : change url
$sessionId = $proxy->login($this->_user, $this->_password); // TODO : change login and pwd if necessary
$pageURL= $this->_page_url;
$result = $proxy->catalogProductList($sessionId);
$product_list = array();
foreach($result as $p)
{
$starttime = microtime(true);
$id = $p->product_id;
$info = new stdclass();
$info->attributes = array('sku', 'name', 'description', 'price', 'url_path');
$product = $proxy->catalogProductInfo($sessionId, $id, NULL, $info);
$image = $proxy->catalogProductAttributeMediaList($sessionId, $id, NULL, 'ID');
$endtime = microtime(true);
$timediff = $endtime - $starttime;
echo "api calls $timediff <br><br>";
$name = $product->name;
$description = $product->description;
$price = $product->price;
$formatted_price = number_format($price, 2);
$image_url = $image[0]->url;
$product_url = $product->url_path;
$product_url = $pageURL.$product_url;
$sku = $product->sku;
$my_product = new Product();
$my_product->id = $id;
$my_product->name = $name;
$my_product->description = $description;
$my_product->price = $formatted_price;
$my_product->image_url = $image_url;
$my_product->product_url = $product_url;
$my_product->sku = $sku;
$product_list[] = $my_product;
}
return $product_list;
The problem with this approach is, each product needs 2 API calls, one for name, description, sku, etc, and another one for the image url. This takes too long, as for 3 products that I have, it takes like 5 seconds to load the page (two api calls for each one is like 1.5s). Is this the normal behavior of Magento API, or there is a problem with my system? Will I need to change all my method?
BTW, I'm testing this in localhost.