2
votes

I'm trying to filter a magento product collection by a multiselect attribute with the following...

$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('sparex_makemodel',
    array('in' => $set
    )
 )
 ->addAttributeToSelect('*');

However when I echo out the query it is not being applied? anybody got a clue why? I'm sure this was working earlier... driving me mad now

2

2 Answers

5
votes

Matthew, you should check attribute option 'Used in Product Listing' is set to 'Yes'.

0
votes

Try like this :

$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*') 
->addAttributeToFilter('sparex_makemodel', array('in'=>$set));
foreach($products as $product)
{
    var_dump($product);
}