我正在尝试在 magento 的类别 View 中设置排序顺序。
在/app/design/frontend/template_name/default/template/catalog/product/list.phtml 中,产品类别的调用方式如下:
$_productCollection=$this->getLoadedProductCollection();
是否有可能使用例如排序这个集合下列? 根据记录,这是行不通的。 ;)
->addAttributeToSort('updated_at','asc')->setOrder('updated_at', 'asc')
提前致谢,
马丁
最佳答案
我所要做的就是执行一些 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"
关于php - Magento - 按类别 list.phtml 中更新的日期排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9318655/