2

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

1 Answer 1

8

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...)

2
  • Can't this is not possible with ORM?
    – blakcaps
    May 6, 2013 at 10:09
  • Added the Magento-way as requested ;)
    – Kenny
    May 6, 2013 at 10:24

Your Answer

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

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