Magento API: get products from a category

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

Hi I can't find anywhere how to get a list of product by category id in Magento API. I am using Ruby XMLRPC library. When i call product.list, I get all my products, each one of them is like this:

{"product_id"=>"165", "sku"=>"mycomputer", 
"name"=>"My Computer", "set"=>"39", 
"type"=>"bundle", "category_ids"=>["27"]}, 
{"product_id"=>"166", "sku"=>"HTC Touch Diamond", "name"=>"HTC Touch Diamond", 
"set"=>"38", "type"=>"simple", "category_ids"=>["8"]}

client.call('call',session_id,'product.list') gives me every product. I tried client.call('call',session_id,'product.list',[:name=>{:like=>"%%computer"}]) gives me products with name containing computer. I tried

client.call('call',session_id,'product.list',[:category_ids=>{:include=>"8"}])
client.call('call',session_id,'product.list',[:category_ids=>"8"])
client.call('call',session_id,'product.list',[:category_ids=>["8"]])

all these fail. I even tried replacing "category_ids" with "category_id"

In addition, the following line is not working either. What did I do wrong?

client.call('call',session_id,'product.info',[:product_id=>xxx])

Neither Magento API and Ruby XMLRPC API can tell me what the correct syntax should be. Anyone has any other suggestions?

You need to use the catalog_category.assignedProducts API method.

From the documentation:

Retrieve list of assigned products

Return: array

Arguments:

int $categoryId - category ID mixed $store - store ID or code

Aliases:

category.assignedProducts

`Reply Or Comment!
Please LogIn to Reply!