filter

Get Only 10 Prodects Magento already uses bestseller products aggregation that can be checked under Admin > Reports > Products > Bestsellers. Thanks to this aggregated data we no longer need to determine the total of all the orders to see which products are sold the most. By the variety of aggregation data we are able to get the most popular products not only from the beginning, but for each specific day, month or year

$productCount = 10;  //insert how much prodect
    $storeId    = Mage::app()->getStore()->getId();      
    $collection = Mage::getResourceModel('reports/product_collection')
                    ->addAttributeToSelect('*')
                   ->addOrderedQty()
                   ->setStoreId($storeId)
                    ->addStoreFilter($storeId)
                   ->addCategoryFilter(Mage::registry('current_category'))
                 ->setOrder('ordered_qty', 'desc')
                ->setPageSize($productCount);                  
 
                Mage::getSingleton('catalog/product_status')
                         ->addVisibleFilterToCollection($collection);
                Mage::getSingleton('catalog/product_visibility')
                         ->addVisibleInCatalogFilterToCollection($collection);    
              get collection

About Author:

Kalpesh Chavada

Kalpesh Chavada is Our Founder & CEO of Akshar Group Technologies. He is serving with 11+ years of experience in different technologies like Magento, WordPress, Laravel, jQuery, Shopify, Branding, and Digital Marketing. He is very good with creative logic and always ready to take on challenges.

Kalpesh Author