Skip to main content

Adding OR query condition for addFieldToFilter Magento

// Adding OR condition to the query

$collection->addFieldToFilter(
    array('sku', 'id'), // columns/field of database table
    array( // conditions
        array( // conditions for 'sku' (first field)
            array('in' => array('text_1', 'text_2', 'text_3')),
            array('like' => '%text')
        ),
        array('gt' => 5) // condition for 'id' (second field)
    )
);

Tags