Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

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