3

I would like to use addFieldToFilter (or other...) in a collection to make this filter :

(item1 = 'value' AND (item2 = 'value1' OR item = 'value2')) OR (item2 = 'value3' OR item = 'value4')

1 Answer 1

0

Whenever dealing with complex filters, I prefer to work with the underlying Zend_Db_Select object. For example:

$collection
    ->getSelect()
    ->where(
        new Zend_Db_Expr("(item1 = '?' AND (item2 = '?' OR item = '?')) OR (item2 = '?' OR item = '?')"), 
        'value1', 
        'value2', 
        'value3', 
        'value4'
    );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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