But I want to be expert .Not just someone who knows how to make settings in admin panel. Lots of books are small one.i want better resource I guess spanning over 1000 pages like java complete reference book.I dont have money (8 lakhs indian rupees) to spend on expensive vids on official site.
Best Way to Learn Magento
extensionsmagento-1.8magento-1.9magento-community
Related Solutions
As stated in the comments the script you have should work nicely for magento version 1.4+.
In the 1.4 version the sales entities were mapped to flat tables that have constraints so everything should cascade nicely.
For versions prior to 1.4 all the entities related to sales (orders, invoices, shipments and creditmemos) were EAV and kept in the same tables. So nothing cascade.
For version prior to 1.4 you can try this script.
This should work for later versions also but I don't think it's needed.
$orders = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('entity_id', (array) $orderIds);
foreach ($orders as $o) {
//load order object - I know it's not ok to use load in a loop but it should be ok since it's a one time script
$order = Mage::getModel('sales/order')->load($o->getId());
$invoices = $order->getInvoiceCollection();
foreach ($invoices as $invoice){
//delete all invoice items
$items = $invoice->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete invoice
$invoice->delete();
}
$creditnotes = $order->getCreditmemosCollection();
foreach ($creditnotes as $creditnote){
//delete all creditnote items
$items = $creditnote->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete credit note
$creditnote->delete();
}
$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment){
//delete all shipment items
$items = $shipment->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete shipment
$shipment->delete();
}
//delete all order items
$items = $order->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete payment - not sure about this one
$order->getPayment()->delete();
//delete quote - this can be skipped
if ($order->getQuote()) {
foreach ($order->getQuote()->getAllItems() as $item) {
$item->delete();
}
$order->getQuote()->delete();
}
//delete order
$order->delete();
}
Both methods have the same result.
The first one you mentioned was introduces in CE-1.6.
In theory that one is the "more correct" than the second one you mentioned second.
Let's say that through some magic Magento supports (natively) other db engine than MySQL.
If you use the first approach in your extensions you won't have to do anything. The extension will work on the other db engine because there should be a driver that transforms the DDL declaration in the query needed for that specific engine.
If you use the second one you might need to write an other install/update script to fit your new db engine.
If you want to be politically correct you should use the first one, but if you don't plan to use something else other than MySQL you shouldn't care.
Best Answer
I would suggest that you start with the basics, which you already can find in small books like "Magento PHP Developer's Guide" or similar.
And then, besides of a running Magento installation and a powerful IDE (I prefer PhpStorm), you need a lot of time for hands on.
Try to dig deep into the core of Magento, the official and free study guide is a good way to start.
And last but not least, code, code, code, code......
It took me at least more than a year working with Magento until I was able to pass the Magento Certified Developer exam.