1

I'm building a custom module and i'm trying get all orders with specific status:

$canceledQuery = Mage::getSingleton('core/resource')->getConnection('core_read')->select()
            ->from('mage_sales_flat_order', 'entity_id')
            ->where('status = ?', 'canceled');

This works very well. But now i'm trying use OR in where, without successs. I have been try this:

$whereCanceled = array();
foreach ($_status as $statusCode => $value) {
    $whereCanceled[] = sprintf('%s=:%s', 'status', $statusCode);
}

$ordersQuery = Mage::getSingleton('core/resource')->getConnection('core_read')->select()
            ->from('mage_sales_flat_order', 'entity_id')
            ->where(implode(' OR ', $whereCanceled));

So, I don't know how use OR right in this case. I found no use for this with OR. Any idea?

1 Answer 1

2

Why not using magento collection standard?

Mage::getResourceModel('sales/order_collection')
  ->addFieldToFilter('status', array('in' => array('canceled','pending'));

Your Answer

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

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