在 magento catal 中按 2 个属性对产品进行排序
在我的 magento 网站上,我们需要按 2 个属性(“制造商”、“名称”)对产品列表进行排序,然后返回到唯一和默认属性“实体 ID”。
看来magento只允许你按1然后entity_id排序。如果需要的话,我不介意以一种黑客的方式来做这件事。
环顾四周,有几个人遇到了这个问题,但似乎没有人提供答案,所以我想我会在之前给出这个答案(也是第一个问题,必须是一个硬汉:))。
On my magento site we have the requirement to sort the product listings by 2 attributes, 'Manufacturer', 'Name' and then falling back to the Unique and default attribute 'Entity ID'.
Seems magento only lets you order by 1 then entity_id. I dont mind having to do this in a hacky way if required.
Looking around a few people have the problem but no one seems to offer an answer so thought I'd give this ago ( First question too, had to be a toughie :) ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一些研究(我不是 php 开发人员 =/ ),以下内容似乎有效:
setOrder() 方法接受一个数组。
$Collection->setOrder(array('attribute1', 'attribute2'), asc);
我不确定有人会想如何使用它,但我修改了 Catalogue/Product/List/ 目录中 Toolbar.php 中的这一行。
因此,我的所有集合均按当前顺序(默认顺序)排序,然后硬编码为按名称排序。仍在对其进行一些测试,但似乎有效......
After some research ( I'm not a php developer =/ ), the following seems to work:
The setOrder() method accepts an array.
$Collection->setOrder(array('attribute1', 'attribute2'), asc);
I'm not sure how anyone would want to use this but I modified this line in Toolbar.php in the Catalogue/Product/List/ directory.
So all my collections are sorted by the current order ( default order ) and then hardcoded to order by name afterwards. Still doing some testing on it but seems to work......