我遇到麻烦使用Magento上的addAttributeToFilter多个选择属性。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
似乎没有什么工作,我有点卡住了。任何建议非常感谢。
是否$产品 - > addAttributeToFilter('make','38')或$ products-> addAttributeToFilter('make',array('eq',38));给你什么? –
它不起作用。因为它是一个多重选择属性,Magento创建'make'为这样一个字符串:28,30,35,38 - 所以如果我需要过滤宝马的id为38的产品,那么我需要它来检查所有这些值。 –
对不起,错过了! –