I want to fetch data from table by applying OR condition in Collection
I am using these lines of code
$collect = Mage::getModel('storelocater/storelocater')->getCollection()->addFieldToFilter(array(
array(
'attribute' => 'country',
'eq' => 'india'),
array(
'attribute' => 'state',
'eq' => 'up')
));
echo $data = $collect->getSelect();
it prints the output
SELECT main_table.* FROM storelocater AS main_table WHERE ((Array = '') OR (Array = ''))
i have also used addAttributeToFilter instead of addFieldToFilter but it returns fatal error
addAttributeToFilter function will work only with EAV entities (like Customers, Products, Categories etc.). addFieldToFilter has slightly different syntax for OR operator:
$collect = Mage::getModel('storelocater/storelocater')
->getCollection()->addFieldToFilter(array('country','state'), array('india','up'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With