2017-08-03 13 views
0

以下のクエリを使用してMagentoストアに最新のフィルタを追加しました。マゼンタで最新の製品フィルタの並べ替え順序を逆にする

UPDATE `catalog_eav_attribute` 
SET `used_for_sort_by` = 1 
WHERE attribute_id = (SELECT ea.attribute_id FROM `eav_attribute` ea WHERE `entity_type_id` = (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_model` = "catalog/product") AND `attribute_code` = "created_at") 


UPDATE `eav_attribute` 
SET frontend_label = "Newest" 
WHERE `entity_type_id` = (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_model` = "catalog/product") and `attribute_code` = "created_at"; 

ソートするためのフィルタは、フロントエンドに反映されますが、それは最初に、古い製品を示し、最後の新製品を、誰がどのように私はこのソート順を変更することができます教えてもらえますか?デフォルトでは

答えて

0

それは昇順として保存されます、あなたはファイルからそれを変更することができます。アプリ/コード/コア/メイジ/カタログ/ブロック/製品/ List.phpコレクションを設定する前に

protected function _beforeToHtml() 
{ 
    $toolbar = $this->getToolbarBlock(); 

    // called prepare sortable parameters 
    $collection = $this->_getProductCollection(); 

    // use sortable parameters 
    if ($orders = $this->getAvailableOrders()) { 
     $toolbar->setAvailableOrders($orders); 
    } 
    if ($sort = $this->getSortBy()) { 
     $toolbar->setDefaultOrder($sort); 
    } 
    if ($dir = $this->getDefaultDirection()) { 
     $toolbar->setDefaultDirection($dir); 
    } 
    if ($modes = $this->getModes()) { 
     $toolbar->setModes($modes); 
    } 

    /************ Our Condition ***********/ 
    if($sort == 'created_at'){ 
     $toolbar->setDefaultDirection('desc'); 
    } 

    // set collection to toolbar and apply sort 
    $toolbar->setCollection($collection); 

てみませんか変更を行う前に必ずこのファイルを上書きしてください。

関連する問題