2012-12-04 54 views
1

嗨,我想获得所有的产品集合的基础上一个multiselect属性。 我写了下面的查询,但它给我所有的产品没有得到过滤。产品收藏过滤多选择属性在magento

$collection = Mage::getModel('catalog/product') 
        ->getCollection() 
        ->addAttributeToSelect('*') 
        ->addAttributeToFilter('author_name', 45) 
foreach($collection as $product){ 
     echo $product->getName().'<br />'; 
    } 

任何一个可以给我查询如何获取由multiselect属性值过滤的集合。

回答

0

尝试addAttributeToFilter('author_name', array('eq' => 45))

1

这是怎么回事?

$collection = Mage::getModel('catalog/product') 
     ->getCollection() 
     ->addAttributeToSelect('*') 
     ->addAttributeToFilter('author_name',array('in' => array('45', '46','47')));