Magento Forum

   
Advanced Collection Filtering
 
tman_f
Sr. Member
 
Total Posts:  85
Joined:  2008-02-12
 

Hello community,

I am trying to grab a collection and filter by attribute values in an OR manner.

For instance:

get all entities where attributeA=something OR attributeB=somethingelse

Any ideas?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
aclark
Jr. Member
 
Total Posts:  2
Joined:  2009-03-05
 

//get sales orders where attribute_1 is null or attribute_2 is null
$salesOrders = Mage::getModel(’sales/order’)->getCollection()
->addAttributeToFilter(array(
array(’attribute’ => ‘attribute_1’, ‘is’ => new Zend_Db_Expr(’null’)),
array(’attribute’ => ‘attribute_2’, ‘is’ => new Zend_Db_Expr(’null’))
));

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top