Magento产品按销量排行How to sort/show products by sold quantity in Magento

Toolbar.php file location:

Your _construct() function should be modified to look something like:
$this->_availableOrder = array(

position’ => $this->__(’Best Value’),

name’ => $this->__(’Name’),

price’ => $this->__(’Price’),

special_price’ =>$this->__(’Special Price’),

‘ordered_qty’ => $this->__(’Quantity soled’),



Next we open the list.phtml inside /template/catalog/product/ folder. And you need to find the:




Expression and cut => paste somewhere to the top of the file. Then we
add some additional logic to that same file. So you should write
something like


// Custom added

$orderFilterType = $this->getRequest()->getParam(’order’);

// Part of original template code, just moved to top of the file

// Custom added

if(isset($orderFilterType) && $orderFilterType === ‘ordered_qty’) {

$storeId = Mage::app()->getStore()->getId();

$_productCollection = null;

$_productCollection = Mage::getResourceModel(’reports/product_collection’)


->setOrder(’ordered_qty’, $this->getRequest()->getParam(’dir’));

to the top of the list.phtml file.

File list.phtml should consists of two major parts:
•List mode, which starting with comment
•Grid mode, which starting with comment

At the beginning of each part (mode) there is a “foreach” loop like
<?php foreach ($_productCollection as $_product): ?>


What we need to do now is to duplicate entire content inside that
foreach loop and set it in if-else statement where if statement would go

本文隐藏内容 登陆 后才可以浏览

inside the if statement.