Magento : Get orders by specific payment method

Magento : Get orders by specific payment method

August 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento : Get orders by specific payment method

Getting Magento Orders by Specific Payment Method

In Magento, retrieving orders based on their payment method involves using the addFieldToFilter function along with the correct field name for the payment method code. Let’s walk through how to achieve this.

Understanding the Order Entity

First, it’s important to understand that in Magento, order data is stored in the sales_order table. The payment method used for an order is recorded in the payment_method column of this table.

When you create an order model and use addFieldToFilter, you’re essentially querying against this underlying database table.

Retrieving Orders by Payment Method

Here’s how to get a collection of orders where the payment method is ‘checkmo’:

$orders = Mage::getResourceModel('sales/order_collection')
    ->addAttributeToFilter('payment_method', array('eq' => 'checkmo'));

In this code:

  • Mage::getResourceModel('sales/order_collection') retrieves the order collection resource model.
  • ->addAttributeToFilter('payment_method', array('eq' => 'checkmo')) filters the collection by adding an attribute filter on the payment_method field. The 'eq' operator means “equals”.

Remember, in Magento 2, the code is slightly different due to the introduction of interfaces and the use of plugins for many operations:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderCollection = $objectManager->create('Magento\Sales\Model(ResourceModel)\Order\Collection');
$orderCollection->addAttributeToFilter('payment_method', array('eq' => 'checkmo'));

Fetching Order Data

The order collection returned by the above methods contains basic information. If you want to fetch detailed data for each order, you need to use getData or load on individual items.

foreach ($orders as $order) {
    var_dump($order->getIncrementId());
    var_dump($order->getGrandTotal());
}

Filtering by Other Criteria

You can also combine the payment method filter with other filters. For example, to get orders placed after a certain date:

$orders = Mage::getResourceModel('sales/order_collection')
    ->addAttributeToFilter('payment_method', array('eq' => 'checkmo'))
    ->addAttributeToFilter('created_at', array('gteq' => $startDate));

Conclusion

Retrieving orders by payment method in Magento is straightforward once you understand the underlying data structure and the available filtering options. Use addFieldToFilter to query against the order collection, specifying the appropriate field name (‘payment_method’) and operator.

Don’t forget that these examples use the older Mage::getResourceModel syntax for Magento 1.x. If you’re working with Magento 2, remember to use the Object Manager or preferably a factory class provided by the module.

For more advanced filtering techniques and order management best practices, I recommend checking out Laravel Company’s guide on Magento Order Management. It provides in-depth coverage of order processing workflows and customization options.

Magento 2 Database Extensions Orders

Our network