2012-02-16 46 views
2

我試圖在magento的類別視圖中設置排序順序。Magento - 在類別列表中更新日期排序list.phtml

在/app/design/frontend/template_name/default/template/catalog/product/list.phtml產品類別被稱爲是這樣的:

$_productCollection=$this->getLoadedProductCollection(); 

有排序使用例如這個集合的可能性下列? 爲了記錄,這不起作用。 ;)

->addAttributeToSort('updated_at','asc')->setOrder('updated_at', 'asc') 

由於提前,

馬騰

+0

任何原因,你不能使用管理選項設置使用屬性的默認排序,並使用一個或多個屬性填充下拉列表?管理員>系統>配置>目錄>前端>「產品列表排序方式」和管理員>目錄>管理類別>「顯示設置」選項卡 – ahillman3 2012-02-16 21:43:01

+0

@ ahillman3不,唯一選項是「最佳值」,「標題」和'price'。 – 2012-02-16 21:51:23

+0

我稍後再來看看,但你需要更多的調查代碼,因爲這些可配置的選項會覆蓋頁面中的硬編碼排序,希望今晚有時間或其他人可以在我做之前協助。 – ahillman3 2012-02-16 22:23:20

回答

5

我只需要做一些SQL查詢。

設置排序依據屬性的前端標籤。

update eav_attribute set frontend_label = "Updated" where attribute_code = "updated_at" 

啓用used_for_sort_by

update catalog_eav_attribute set used_for_sort_by = 1 where attribute_id = (select attribute_id from eav_attribute where attribute_code = "updated_at") 

設置的updated_at爲標準排序值(也可以在後臺完成)

update core_config_data set value = "updated_at" where path = "catalog/frontend/default_sort_by" 
0

我發現了一個博客貼子,你想要做什麼。還有額外的編碼要求,但它會給你你想要的額外的排序功能。

http://www.excellencemagentoblog.com/magento-category-page-product-sorting

一切首節過後,開始與定製產品排序在分類頁爲您提供了必要的新功能的替代和附加功能。

讓我知道如果你認爲缺少某些東西,並且需要更多的功能。