Question

How to get all the orders with the 'ccsave' as the payment method?

Was it helpful?

Solution

If you have access to the database you can simply run the following query:

SELECT sfo.*, sfop.*
FROM sales_flat_order_payment sfop
INNER JOIN sales_flat_order sfo ON sfo.entity_id = sfop.parent_id
WHERE sfop.method = 'ccsave';

If you don't have access to the database to run queries you can retrieve what you want via the following code snippet:

<?php
$orders = Mage::getModel('sales/order')->getCollection();
$orders->getSelect()->join(
    array('p' => $orders->getResource()->getTable('sales/order_payment')),
    'p.parent_id = main_table.entity_id',
    array()
);
$orders->addFieldToFilter('method','ccsave');

foreach ($orders as  $order) {
    echo $order->getEntityId() . PHP_EOL;
}

This will give you a list of order information of all orders that were paid via the method 'ccsave'. (You can adjust the WHERE-condition if needed...)

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top