Magento SOAP API: Getting Top Selling Products

I just learned Magento and its web services API for a new job. I've just managed to create some basic PHP scripts getting products in specific categories. Now I need to get the best selling products, but I am trying to find good documentation on this. Any help, pointers, example code or anything else is really greatly appreciated ...

Thank,

Tom

+2


source to share


2 answers


I believe there is no way to do this using the Web Services API. However, inside Magento native PHP, you can get top-selling products with the following parameters:



$bestselling_products = Mage::getResourceModel('reports/product_collection')
  ->addAttributeToSelect('*')
  ->setStoreId(1)
  ->addOrderedQty($from, $today)
  ->addAttributeToFilter('visibility', $visibility)
  ->addAttributeToFilter('status', 1)
  ->setOrder('ordered_qty', desc);

      

+1


source


I think there is no direct way to do this from the API. Perhaps you can do this by fetching all sales orders and find out which of the products was the most ordered.



A quick way is also to extend the api to add a method that will do what you want.

0


source







All Articles