2

I am following this article. I would like to retrieve all Orders from Database. Can anyone say how can I do that??

3 Answers 3

1

Using collection you can do it easily with one single line:

$orders = Mage::getResourceModel('sales/order_collection');

Then depending on what you want to do you can loop through them:

foreach ($orders as $order) {
    // Do something
}

NB: using foreach may be resource and time consuming, I suggest you think about using the walk iterator by reading this link: Is it possible to iterate over Magento collections with pagination natively?

1

Been answered the Magento Way. If you want to just excess them in the database themselves than let me know as it's a combination of several areas.

https://stackoverflow.com/questions/9741114/how-to-get-all-orders-and-all-invoices-from-php-in-magento

0

If some one needs to read huge amount of data using command object, without having memory problems, you can use magento walk iterator.

example code on http://www.rosenborgsolutions.com/collection-walk-iterator.php

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.