I am following this article. I would like to retrieve all Orders from Database. Can anyone say how can I do that??
3 Answers
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?
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.
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