I am developing a cron supposed to capture all the recent orders from a specific payment method, but I currently have a problem getting all the orders from a specific payment method.

I thought that the payment method would be in the sales_flat_order table, but it isn't, so I can not use something like :

$ordersCollection = Mage::getModel('sales/order')->getCollection()
    ->addFieldToFilter('payment_method', $paymentMethod);

How can I filter all the orders and only get the one with a certain payment method ?

2 Answers 2


Try to do this using joining the collections:

$table_prefix = Mage::getConfig()->getTablePrefix();
$order_table = $table_prefix.'sales_flat_order';
$on_condition = "main_table.parent_id = $order_table.entity_id";

$orderCollection =  Mage::getModel('sales/order_payment')->getCollection()->addFieldToFilter('method',"PAYMENT_METHOD_NAME");    // for e.g checkmo

$orderCollection ->getSelect()->join($order_table,$on_condition);

foreach($orderCollection as $order):
 echo '<br/>ORDER # : '.$order->getIncrementId();

Hope this will help!


Try following code:

 $ordersByPaymentCheckMo = Mage::getResourceModel('sales/order_payment_collection')            

foreach($ordersByPaymentCheckMo as $orderByPayment):
      $order = Mage::getModel('sales/order')->load($orderByPayment->getParentId());
     echo '<br/>ORDER # : '.$order->getIncrementId();

Hope this work for you.

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.