Is it possible to get the SQL condition like this:

WHERE ( (field_1 = 'a' AND field_2 = 'b') OR (field_1 = 'c' AND field_2 = 'd') OR ... ) ?

using addFieldToFilter() method?

I know about getSelect() method. The question about addFieldToFilter method only.


Hey In my knowledge we can do it not same as you mentioned in your question but yes likely we can do it as:

        array('attribute'=> 'someattribute','like' => 'value'),
        array('attribute'=> 'otherattribute','like' => 'value'),
        array('attribute'=> 'anotherattribute','like' => 'value'),

here in array we need to specify the attribute and value and it will give you output as in where clause like:

WHERE ((someattribute LIKE 'value') OR (otherattribute LIKE 'value') OR (anotherattribute LIKE 'value'))

For more information you can look into this answer too.Hope this help.

  • Thanks, but I asked about addFieldToFilter method, not addAttributeToFilter. I use a simple (not-EAV) collection. – sergei.sss Nov 13 '18 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.