I've been wrestling with Magento for the last month or so and I'm still trying to figure it out. So this is a case of the blind leading the blind. There's little in the way of documentation and the forum/wiki is chaotic at best. Not only that, but there are several solutions that are either outdated or far from optimal. I'm not sure if you have a project or just trying to figure it out, but it's probably easier if you started with modifying existing functionality as opposed to creating something completely new. For that I'd definately go with the "Recommended articles for developers" in the wiki. The new payment method one was a real eye-opener.
For debugging I'd definitely recommend using FirePHP and looking at your HTML source when something goes wrong. The ole echo debug method doesn't really work all that well.
The general architecture is so mind-numbingly complex, that even if I completely understood it, I'd need to write a book to cover it. The best I can do is give you advice I wish someone had given me when I first started...
Stay away from core files. Don't modify them, instead write your own module and override what you need.
Magento uses config files consisting of XML to decide what it needs to do. In order to get it to run your own stuff as opposed to core functionality you need the correct xml. Unfortunately there is no guide on how to build you XML; you need to look at examples and do some serious testing. To complicate things the content of these files is largely case-sensitive. However if you master these you can override any part of the basic functionality which makes for a very powerful system.
Magento uses methods like Mage::getModel('mymodel')
, Mage::getSingleton('mysingleton')
, Mage::helper('myhelper')
to return objects of certain classes. It finds these by default in its core namespace. If you want it to use your own, you need to override these in your config.xml
file.
The name of your classes must correspond to the folder they're in.
A lot of the objects in Magento ultimately extend something called a Varien_Object
. This is a general purpose class (kind of like a swiss army knife) and its purpose in life is to allow you to define your own methods/variables on the fly. For example you'll see it used as a glorified array to pass data from one method to another.
During development make sure you caching is disabled. It'll make magento excruciatingly slow, but it'll save you a lot of head trauma (from banging it on your desk).
You'll see $this
being used a lot. It means a different class depending on what file you see it. get_class($this)
is your friend, especially in conjunction with FirePHP.
Jot things down on paper. A lot. There are countless little factoids that you're gonna need 1-2 days after you encounter them.
Magento loves OO. Don't be surprised if tracing a method takes you through 5-10 different classes.
Read the designer's guide here. It's meant mostly for graphics designers, but you need it to understand where and why the output from your module will end up. For that don't forget to turn on "Template path hints" in the developer section of the admin panel.
There's more, but I'll stop here before this turns into a dissertation.