2012-10-22 131 views
1

我已經試過這和它的部分工作Magento:如何對產品進行最新排序「無視類別」?

http://www.dconstructing.com/2011/04/07/sort-magento-catalog-by-date-added/

但具有多個類別的網頁上,它按類別爲第一級,才把它按每個類別中的產品。

因此,某個類別中的較早產品出現在另一個類別的較晚產品之前。我不想那樣。我想要一個平面排序,只按「位置」(magento term)排序,而不管類別如何。

我該如何做到這一點?

+0

這不能在佈局XML中完成。如果你想讓工具欄等工作正常,你需要使用目錄/圖層對象。 – benmarks

+0

Ben,出於好奇,爲什麼不能使用: created_at最新在category.xml中的工具欄塊定義裏面? – pspahn

+0

@pspahn我不明白你的意見,OP是要求職位,而不是'created_at'? – benmarks

回答

0

或者到格拉的答案,而裏面toolbar.phtml你可以使用:

<?php if($this->getCurrentDirection() == 'desc') : ?> 
    <?php $this->addOrderToAvailableOrders('created_at','Newest') ?> 
<?php else : ?> 
    <?php $this->addOrderToAvailableOrders('created_at','Oldest') ?> 
<?php endif; ?> 
0

第1步:從app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php實現這個副本的文件Toolbar.php。創建本地目錄結構和粘貼Toolbar.php如下圖所示app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php

步驟2:圍繞線232,你應該看到setCollection()功能下面的代碼

if ($this->getCurrentOrder()) { 
    $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection()); 
} 

與下面給出的新的代碼替換上面的代碼

if ($this->getCurrentOrder()) { 
    if(($this->getCurrentOrder())=='position'){ 
     $this->_collection->setOrder('entity_id','desc'); 
    } 
    else { 
    $this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection()); 
    } 
}