Your main problem in this whole scenario is that you need live data (orders and history). Magento's import/export mechanisms do a reasonable job on basics like product and customer account data, poorly or not at all on categories and sales data (orders, invoices, etc), the latter being your interest.
Assuming you meant in your description that your live server is 1.7.x.x and your test is 1.4.x.x
Test your backup abilities, you will need to know if this works sooner or later.
Tar your application and backup your database on the live server.
Empty everything off the test server and clear all the tables in the database.
Restore your application and database to your test server, set file/folder ownership and permissions, change your baseURLs and make local.xml changes. Instant update of your test server from 1.4.x.x to 1.7.x.x
Reapply your changes to take it back to the configuration you had.
Now, if you're going in the other direction (1.4.x.x on the live and 1.7.x.x on the test), do all the above and then upgrade your test server to the new version. It will ensure you have done the upgrade several times before the final upgrade to the live server. You will have worked all the kinks out and the live upgrade goes a lot smoother that way. Reapply your changes to take it back to the configuration you had.
It truly is easier this way, all that import/export pie-in-the-sky goofiness recommended for version upgrades over on the MagentoCommerce forums and Wiki is a recipe for disaster and membership in the local looney bin. Nobody working with live ERP software puts up with the added complexity for the incomplete results it delivers.
IMPORT/EXPORT UPGRADES ARE THE REAL LIFE EXAMPLE OF "WORK HARDER NOT SMARTER".
Plus, being really good at doing site restores on a separate server banishes the adrenaline freeze, panic and heart attack you have when your site goes up in smoke without current backups. Keep current backups with a tested restore routine and it probably won't happen, but you know what to do if it does.
NOTE: And start by doing a full backup on your test system.
Ok,
Firstly I think you are not understanding what Models and Collections are.
There is no attribute, or value called period. Not sure where you got that from.
A model as in Mage::getModel('sales/order')
will be an object containing the relevant data of one item. Generally that is laoded directly by the entity_id of the order that you are interested in. (->load($order_id)
)
So, considering the code you supplied in your question, what you have tried would not work, as you are wanting back a Collection
of Models
So, to get a collection, you would use Mage::getModel('sales/order')->getCollection()
, and then apply filters to that collection (in your case date ranges). You would then be able to iterate the collection, and deal with each model held in the collection in any way you want.
To answer your question:
$fromDate = date('Y-m-d H:i:s', strtotime(<YOUR START DATE>));
$toDate = date('Y-m-d H:i:s', strtotime(<YOUR END DATE>));
/* Get the collection */
$orderCollection = Mage::getModel('sales/order')->getCollection()
->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate))
->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE));
you woudl then do something with the collection.
foreach ($orderCollection as $orderModel) {
// do somehing with the Model
}
Hope that helps.
EDIT1:
To test the query, output the raw sql, and run it in a mysql client.
$select = $orderCollection->getSelect();
echo (string) $select;
Best Answer
Use this extension for delete order.
http://www.magentocommerce.com/magento-connect/seamless-delete-order.html
Or you can use below code to delete your order.