Magento Themes and Magento Extensions

Show Top Selling Products in Magento

Share

Show Top Selling Products in Magento

This a simple best seller product viewing code. you can put it in template. this will grab all the sold product according to sold amount, you can simply put a loop break to show number of products you want to show .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php /* Best Seller*/
$visibility = array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
);
$storeId = Mage::app()->getStore()->getId();
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addOrderedQty()
->addAttributeToFilter('visibility', $visibility)
->setOrder('ordered_qty', 'desc');
//print_r($_productCollection);
foreach($_productCollection as $bs_product){
echo '<li><a href="'.$bs_product->getUrl_path().'">'.$bs_product->Name.'</a></li>';
}
?>

Comments are closed.