【问题标题】:Magento - Sort on date updated in category list.phtmlMagento - 按类别 list.phtml 中更新的日期排序
【发布时间】:2012-02-16 20:36:55
【问题描述】:

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

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

$_productCollection=$this->getLoadedProductCollection();

是否有可能使用例如对这个集合进行排序?以下? 作为记录,这是行不通的。 ;)

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

提前致谢,

马丁

【问题讨论】:

  • 有什么理由不能使用管理选项来设置使用属性的默认排序,并使用一个或多个属性填充下拉列表?管理>系统>配置>目录>前端>“产品列表排序方式”和管理>目录>管理类别>“显示设置”选项卡。
  • @ahillman3 不,那里唯一的选项是“最佳价值”、“标题”和“价格”。
  • 稍后我会再看一些,但您需要更多地研究代码,因为这些可配置选项会覆盖您在页面中的硬编码排序。希望今晚我有时间,或者其他人可以在我之前提供帮助。

标签: php sorting magento


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

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

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

    如果您认为缺少某些内容并需要更多功能,请告诉我。

    【讨论】:

      猜你喜欢
      • 2012-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多