Magento addAttributeToFilter with Multiple Select

Ada*_*oss 4 magento addattribute

我在Magento多选属性上使用addAttributeToFilter时遇到了麻烦.

我有汽车制造的多重选择属性,所以内容是'奥迪','宝马'等等.在我的例子中,我有一个轮胎产品,我从多个选择中选择了5个.

我想展示制作'宝马'作为其选定领域之一的产品.

我尝试了以下所有不起作用:

$products->addAttributeToFilter('make', array('like' => '%BMW%'));  
$products->addFieldToFilter('make', array('like' => '%BMW%'));  
$products->addAttributeToFilter('make', array('like' => '%38%')); // id of the attribute option
Run Code Online (Sandbox Code Playgroud)

似乎没什么用.

Ale*_*ley 11

解决方案是使用如下Find In Set查询:

$this->_productCollection->addAttributeToFilter("make", array("finset"=>"38"));
Run Code Online (Sandbox Code Playgroud)

可以在这里看到讨论:http://www.magentocommerce.com/boards/viewthread/201312/

以及不同选项的列表:http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-8-varien-data-collections