-
-
Save deivisonarthur/4477451 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//for AND | |
$collection = Mage::getModel('sales/order')->getCollection() | |
->addAttributeToSelect('*') | |
->addFieldToFilter('my_field1', 'my_value1') | |
->addFieldToFilter('my_field2', 'my_value2'); | |
echo $collection->getSelect()->__toString(); | |
//for OR - please note 'attribute' is the key name and must remain the same, only replace //the value (my_field1, my_field2) with your attribute name | |
$collection = Mage::getModel('sales/order')->getCollection() | |
->addAttributeToSelect('*') | |
->addFieldToFilter( | |
array( | |
array('attribute'=>'my_field1','eq'=>'my_value1'), | |
array('attribute'=>'my_field2', 'eq'=>'my_value2') | |
) | |
); | |
link : http://stackoverflow.com/questions/3826474/magento-addfieldtofilter-two-fields-match-as-or-not-and | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment