magento 按位置排序属性选项集合?
您好,
我正在尝试按管理属性面板中输入的“位置”对属性选项值数组进行排序。我似乎已经尝试了一切,有谁知道这怎么可能?
我确信这会起作用:
$_collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setStoreFilter(0)
->setAttributeFilter($_productAttribute->getId())
->addAttributeToSort('position')
->load();
但事实并非如此。任何帮助将不胜感激!
Greetings,
I am trying to sort an array of attribute option values by their "position" as entered in the manage attributes panel. I seem to have tried everything, does anyone know how this is possible?
I thought for sure this would work:
$_collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setStoreFilter(0)
->setAttributeFilter($_productAttribute->getId())
->addAttributeToSort('position')
->load();
But it didn't. Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我已经在之前的项目中体验过 addAttributeToSort 了:也许这个函数直到今天才起作用,尝试使用 setOrder('columname') 或尝试将您的 magento 更新到最新版本
I've alredy been experienced with addAttributeToSort in a previous project: maybe this function doesn't works until today try with setOrder('columname') or try to update your magento to last version
工作得很好。在 Magento 1.6 中 + 使用
setOrder('sort_order')
。Working great. In Magento 1.6 + use
setOrder('sort_order')
.在 app/design/frontend/default/default/template/manapro/filtercheckboxes/items.phtml 的开头添加以下代码:
并在 foreach 循环中将 $this->getItems() 替换为 $array 。
At the begining of app/design/frontend/default/default/template/manapro/filtercheckboxes/items.phtml add following code:
And replace $this->getItems() with $array in foreach loop.
当它读取集合时,它将加载连接查询到集合并使用加载函数。因此,如果您在之后添加订单,
就像:
As it eav collection it load load join query to collection and using load function. so if you add order after
just like: