开发者

Magento SOAP API: fetching most sold products

开发者 https://www.devze.com 2022-12-26 18:49 出处:网络
I’m just learning Magento and its Web Services API for a new job. I’ve just managed to build some basic PHP scripts fetching products in specific categories. I now need to fetch the best-selling pro

I’m just learning Magento and its Web Services API for a new job. I’ve just managed to build some basic PHP scripts fetching products in specific categories. I now need to fetch the best-selling products, but am struggling to find good documentation on this. Any help, pointers, sample code or anything else really w开发者_JS百科ould be much appreciated...

Thanks,

Tom


I believe there's no way to do this with the Web Services API. However within Magento's own PHP you can get the most sold products with the following:

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


I think there is not a direct way to do that with the API. Maybe you can do so by retrieving all the sales orders, and find which of the products have been the most ordered.

A quick way would also be to extend the api to add a method which will do what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消