Magento-在分类列表.phtml中按更新日期排序


Magento - Sort on date updated in category list.phtml

我正在尝试为magento设置类别视图中的排序顺序。

在/app/design/frontend/template_name/default/template/catalog/product/list.phtml中,产品类别是这样命名的:

$_productCollection=$this->getLoadedProductCollection();

是否有可能使用以下方法对该集合进行排序?郑重声明,这不起作用。)

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

提前感谢

Maarten

我所要做的就是执行一些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" 

我发现了一篇可以满足你需求的博客文章。需要额外的编码,但它将通过额外的排序功能为您提供所需的内容。

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

第一部分之后的所有内容,从类别页面中的自定义产品排序开始,为您提供了新功能所需的覆盖和附加功能。

如果您认为缺少什么,并且需要更多功能,请告诉我。