Magento:获取导航过滤器项目的属性
因此,我越来越熟悉 Magento 使用的分层导航,并且我确实注意到可以获取项目的各种属性,例如名称或字符串值,但是有一个属性我无法从模型中轻松获取正在使用 ('catalog/layer_filter_item'): 位置。
有谁知道如何获取属性过滤选项的位置,比如有一个位置为 2 的洋红色 - 我怎样才能得到那个 2?
问题也可能是——如何从表 eav_attribute_option 中获取 sort_order ...如果有帮助的话。
感谢您的帮助:)
So I'm getting more and more familiar with the layered navigation Magento employs, and I do notice that it's possible to get various attributes of the items, like Name or a string Value, however there's one attribute I cannot get easily from the model I'm using ('catalog/layer_filter_item'): position.
Does anyone know how to get the position of the attribute filtering option, like say there's a color Magenta with a position of 2 -- how can I get that 2?
The question could also be -- how do I get the sort_order out of the table eav_attribute_option... if that helps.
Thanks for any help :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试通过放置来读取所有类方法
Try reading all class methods by putting
必须可以修改过滤器资源生成的 SQL,从而使值作为 SELECT 列返回。然而,这听起来很难,所以在模板 (template/catalog/layer/filter.phtml) 中您会看到以下内容:
将其更改为:
并且
$_idx
将是一个随 sort_order 一起增加的数字。它不会完全相同,数组的键是从零开始且连续的。如果您给出的位置为 1、3 和 1, 10 它仍然会显示为 0, 1, 2。我承认这是一个妥协,但可能足以满足您的目的。
It must be possible to modify the SQL generated by the filter's resource and so cause the value to be returned as a SELECT column. However that sounds hard so instead in the template (template/catalog/layer/filter.phtml) where you see this:
Change it to:
And
$_idx
will be a number that increases along with sort_order. It will not be exactly the same, the keys of an array are zero-based and contiguous. If you gave positions of 1, 3 & 10 it would still come out as 0, 1, 2.I admit it's a compromise but might just be good enough for your purposes.