I'm stuck on something, I've look on every results I have found on Google but I haven't found the solution yet.
I'm trying to do a SQL request which look like that:
SELECT `main_table`.*, `order`.`increment_id` AS `order_increment_id`, `order`.`status` AS `order_status` FROM `magentoudropship_po` AS `main_table`
INNER JOIN `magentosales_flat_order` AS `order` ON main_table.order_id=order.entity_id
WHERE ((main_table.udropship_status = 0 AND main_table.created_at > '22/04/2015') OR (main_table.udropship_status = 9 AND main_table.created_at > '20/04/2015'))
I haven't found how to insert an AND condition inside a OR condition ...
Here's my actual code:
$collection = Mage::getModel('udpo/po')->getCollection()
->addFieldToFilter(
array('main_table.udropship_status', 'main_table.udropship_status'),
array(array('eq' => Unirgy_DropshipPo_Model_Source::UDPO_STATUS_PENDING), array('eq' => Unirgy_DropshipPo_Model_Source::UDPO_STATUS_ACK))
);
$collection->getSelect()->join(
array('order' => Mage::getSingleton('core/resource')->getTableName('sales/order')), 'main_table.order_id=order.entity_id',
array('order_increment_id' => 'increment_id', 'order_status' => 'status')
);
$collection->load();
And this is the request I have for now:
SELECT `main_table`.*, `order`.`increment_id` AS `order_increment_id`, `order`.`status` AS `order_status` FROM `magentoudropship_po` AS `main_table`
INNER JOIN `magentosales_flat_order` AS `order` ON main_table.order_id=order.entity_id
WHERE ((main_table.udropship_status = 0) OR (main_table.udropship_status = 9))
Do you know how to achieve a condition like ((condition AND condition) OR (condition AND condition))
?
Zend_Db_Select
's methods?