Magento 在类别列表页面中排序

Magento sorting in cateory listing page

我在这里得到了以下代码:app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php 并且我得到了以下函数。 我们可以在这里添加更多代码来解决这个问题吗?:-- 产品应排序如下:-

Products Name: Prices

A:  0

BC:  0

B:  0

BD: 0

CD: 0

C:  

     public function setCollection($collection)
{
    $this->_collection = $collection;

    $this->_collection->setCurPage($this->getCurrentPage());

    // we need to set pagination only if passed value integer and more that 0
    $limit = (int)$this->getLimit();
    if ($limit) {
        $this->_collection->setPageSize($limit);
    }
  /*   if ($this->getCurrentOrder()) {
        $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
    } */

    if ($this->getCurrentOrder()) {
        if(($this->getCurrentOrder())=='price'){
            $this->_collection->setOrder('entity_id','asc');
        }
        else {
            $this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
        }
    }
    return $this;
}

我想按类别从高到低显示产品列表 低价如果所有产品的价格都相同,那么所有产品将在页面加载时默认按字母顺序显示。

是的,我得到了答案:

public function setCollection($collection)
{
    $this->_collection = $collection;

    $this->_collection->setCurPage($this->getCurrentPage());

    // we need to set pagination only if passed value integer and more that 0
    $limit = (int)$this->getLimit();
    if ($limit) {
        $this->_collection->setPageSize($limit);
    }
    if ($this->getCurrentOrder()) {
        $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
    }
        if ($this->getCurrentOrder()) {
        if($this->getCurrentOrder()=='price')
        {
        $this->_collection->setOrder('price','asc');
        $this->_collection->setOrder('name','asc');
        }
        }
        else {
            $this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
        }
    return $this;
}