Magento – Filter collection by multiple attributes with OR not AND

collection;multiselect-attribute

Trying to filter a collection to show results where attribute_1 = something OR attribute_2 = something. I can get it to filter by one or the other, but not if one is true OR the other is true.

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('attribute_1');
$collection->addAttributeToSelect('attribute_2');

$collection->addFieldToFilter(array(
array("attribute"=>"attribute_1","eq"=>"something"),
array("attribute"=>"attribute_2","eq"=>"something")
));

Best Answer

Try this instead:

$collection->addAttributeToFilter(array(
    array("attribute"=>"attribute_1","eq"=>"something"),
    array("attribute"=>"attribute_2","eq"=>"something")
    ));