Magento-分类产品集合
我有一个需要过滤的产品集合。为此,我已覆盖“Mage\u目录\块\产品\列表”,并具有以下代码:Magento-分类产品集合,magento,sorting,collections,filter,product,Magento,Sorting,Collections,Filter,Product,我有一个需要过滤的产品集合。为此,我已覆盖“Mage\u目录\块\产品\列表”,并具有以下代码: $collection = parent::_getProductCollection(); $collection->addAttributeToFilter('language', array('in' => array('B','C','E'))); $collection->addAttributeToSort('language', 'DESC'); return $
$collection = parent::_getProductCollection();
$collection->addAttributeToFilter('language', array('in' =>
array('B','C','E')));
$collection->addAttributeToSort('language', 'DESC');
return $this->_productCollection;
在前端,它以E、C、B的形式进行排序
如果我将属性sort设置为'ASC',则排序的形式为B、C、E
但是,我需要指定E、B、C的顺序
有什么办法可以做到这一点吗
谢谢你的帮助
更新
我试过fin_Set并查看了您发送的链接。我试过密码:
$collection = parent::_getProductCollection();
$collection->addAttributeToFilter('language',
array('finset'=>'E','C,E,B'));
return $this->_productCollection;
但是,这仅显示设置为“E”的产品。我也尝试了您提供的代码,但收到的产品列表为空 试试这个:
parent::_getProductCollection()
->addAttributeToFilter('language', array('finset'=>'B,C,E'));
return $this->_productCollection;
finset
映射到MySQL。请告诉我这个问题的最新情况。我已经尝试了你的代码和基于你给出的链接的修改。我没有说array('finset'=>'E','C,E,B')
,而是array('finset'=>'C,E,B'))
。我认为它甚至不像你写的那样有效。