Skip to content

Instantly share code, notes, and snippets.

@deivisonarthur
Forked from anonymous/filtro.php
Created January 7, 2013 18:55
Show Gist options
  • Save deivisonarthur/4477451 to your computer and use it in GitHub Desktop.
Save deivisonarthur/4477451 to your computer and use it in GitHub Desktop.
//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