Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Getting all product information by category using SOAP
 
jpappe
Jr. Member
 
Avatar
Total Posts:  5
Joined:  2008-04-22
Edinburgh
 

I’m trying to write a SOAP client for querying a Magento store from an external application.  I’m starting small by just trying to navigate through the catalog, showing all products in a category as well as sub-categories.

The problem I have is that the “catalog_category.assignedProducts” operation returns information such as product_id, sku, etc on all the products in the category, so if I want to do things like display the product name, I have to do a separate query for each product in the category.  There must be a more efficient way to get this information!  Does anybody know how this might be done?

I’ve tried looking at the operations under catalog_product, but it’s unclear how I could filter by category.  Any help would be appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jpappe
Jr. Member
 
Avatar
Total Posts:  5
Joined:  2008-04-22
Edinburgh
 

It looks like I’ve just solved my own problem using the “multiCall” function.  If I have X products in a category, rather than issue X queries, issue 1 multiCall that includes X operations.

The code looks like this:

$client = new SoapClient($my_url);
$session $client->login($username$api_key);

// get a list of all products in category $category_id
$products $client->call($session'catalog_category.assignedProducts'$category_id);

// now create a set of queries that will all get issued at once
$queries = array();
foreach(
$products as $product{
     $queries[] 
= array('catalog_product.info'$product['product_id']);
}

$product_info 
$client->multiCall($session$queries);

The only problem I have now is that this seems to fetch all products in subcategories as well.  Anybody know how to narrow it down to this category only?

 
Magento Community Magento Community
Magento Community
Magento Community
 
JKwan13
Member
 
Total Posts:  63
Joined:  2008-06-12
 

Sorry, I dont have an answer to your question, but I just want to thank you for that tip.  This can literally save me hours of time, I can’t believe I overlooked that multicall function.

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