2016-04-26 8 views
-1

実際には名前の昇順と降順の並べ替えが必要です。 私atributeがある「名前」ので、私は/app/code/local/Mage/Catalog/Block/Product/List/Toolbar.phpでこれをやった:Magento 1.9で新しい「並べ替え」を追加する

public function setCollection($collection) 
{ 
    $this->_collection = $collection; 
    $this->_collection->setCurPage($this->getCurrentPage()); 
    $limit = (int)$this->getLimit(); 
    if ($limit) { 
     $this->_collection->setPageSize($limit); 
    } 
      if ($this->getCurrentOrder()) 
     { 
      if(($this->getCurrentOrder()) == 'name')  
       { 
        $this->_collection->addAttributeToSort('name','desc'); 
       } 
       /* 
      else if(($this->getCurrentOrder()) == 'name','asc') 
       { 
        $this->_collection->addAttributeToSort('name','asc'); 
       }*/ 
      else 
       { 
        $this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection()); 
       } 
     } 
    return $this; 
} 

は悲しげに、ほとんどのフォルダやファイルに名前を付けるスキップが、それは限りelse if (asc)部分がコメントアウトされているように動作し、これは常にいくつかのガイドに繰り返される加えます。 昇順に2番目の名前を追加するにはどうすればよいですか?

+0

あなたはさらに何をしようとしているのか説明できますか? –

+0

実際...私はできません。この部分の私たちの責任あるガイは亡命者になり、私は何をやっているのか知りません!しかし、周りの不器用さによって、私は偶然、一歩前進しました。 Catalog/manage Atributesの下で、名前をAscendingに変更し、Descendingという名前の別の属性を作成しました。上のコードにそれらを書いた後、Magentoは作業を開始しました! – Zonk

答えて

0

管理パネルカタログ - >属性 - >属性の管理 - >属性コードの下にある属性 '名前'を検索してください。検索ボタンをクリックします。属性名をクリックします。 「製品リストでソートする」オプションを「はい」としてください。属性を保存します。

下記の画面をご覧ください。それはあなたを助けるかもしれません。 click here

関連する問題