This question already has an answer here:

Need to generate the following query with getCollection() however unable to figure it out.

(id_path = '12/xyz') OR (request_path = '/abc' AND store_id = '1')

Tried the following but I need it the other way:

//gives (...) AND (.. OR ..)

$collection->addFieldToFilter('id_path', '12/xyz');
    array('store_id', 'request_path'), 
    array('1', '/abc')

marked as duplicate by Manashvi Birla, Priyank, Aditya Shah, Murtuza Zabuawala, Piyush Dec 25 '18 at 9:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Try this collection

$subSelect = clone $collection;
$subSelect->addFieldToFilter('request_path', '/abc')->addFieldToFilter('store_id', 1);
    array('id_path', 'entity_id'),
        array('eq' => '12/xyz'),
        array('in' => $subSelect->getAllIds()),

  • Hey, thanks - that looks like a way to do it without having to write raw where SQL. – Sushil Dec 25 '18 at 8:33
  • Well it was just for debugging, the var_dump line – Tuyen Nguyen Dec 25 '18 at 8:34

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