Magento is the “Big Daddy” of e-commerce platforms. It powers some of the biggest and most prestigious e-shops on the web. I’ve been using the platform for a while now. While I’ve gradually learned the admin area, tweaking a server to run Magento well, some of the key extensions, and how to “hack” a theme, I have yet to delve into extension development. This book aims to teach people like me how to develop for the platform. Does it succeed? Read on and find out.
Allan MacGregor, the author, is a Magento Certified Developer. He has the unenviable task of explaining how the Magento codebase works. Magento is big. I mean mind-bendingly large – over 30,000 files and 1.2 million lines of code, according to the book. The author’s task is to explain this mammoth system from a programmer’s perspective in a shade under 250 pages. Frankly, this is an almost impossible task. To truly explain the intricacies of Magento, the page count would need to grow by a factor of 10. The book concentrates on explaining key Magento concepts and letting the reader use the internet to flesh out these concepts for their specific requirements. Budding Magento coders will find themselves flipping between this book, their IDE and several browser tabs as they strive to get to grips with the labyrinth that is the Magento codebase.
The introductory chapter describes how to create an environment for Magento, and install the application. Allan goes into some detail here, installing Ubuntu on VirtualBox, installing the LAMP stack, and installing Magento. He even shows how to use Vagrant and Chef to automate the process, and suggests some IDEs for Magento coders to use.
In the next chapter, Allan moves onto Magento fundamentals, explaining how the system is build upon the Zend framework, and describing the folder structure. He then shows the key files Magento uses to bootstrap and route, and describes Magento’s take on the MVC (Model-View-Controller) architecture pattern.
The next topic is ORM and Data Collections. Allan provides a custom script that allows Magento models to be queried interactively. This tool will be invaluable as it really allows the reader to get a feel for how Magento sees its world, without having to hack the core, or theme, or build extensions in order to be able to expose Magento’s innards. We see the Varien Object and look at some of the core code – at this point I was feeling a little overloaded, but I have to say that Allan tackles the subject material in a very logical way. Indeed reading the Table Of Contents is an excellent two minute exercise in understanding the key concepts you’ll need to grasp to excel with Magento. The EAV model is how Magento’s data is stored in the database – if you’ve not come across this concept before, it will hurt your brain. While it is rare to directly interact with the database, understanding how it is laid out is still important for grasping how the the system works.
The next chapters – Frontend Development and Backend development allow us to get our hands dirty and create some practical code. These chapters are very hands-on. You’ll only understand if you build the extension as you read. I had lots of unanswered questions here, but the answers would have required many more pages, and raised further questions of their own. It would be uncharitable to expect Allan to cover all bases in a single volume. If you work your way through these chapters, you’ll have a far better understanding of how to build an extension, and you’ll know the right questions to ask Google when you begin writing your own extensions. Magento’s own forum is an excellent resource for follow-on questions, and Google excels at finding the nuggets you’ll need to take you to the next level.
The chapter on the Magento API gives a good overview of Magento’s core API which allows Magento to securely communicate with other systems, including the recently introduced RESTful API functionality. The book closes with an excellent chapter on quality/texting and another on deployment/distribution, before a final “Hello Magento” chapter gives a quick overview of creating a barebones extension.
Having read the book, I confirmed my suspicions that I’ll need 6 months to a year to really get my head around Magento. The first step will be to re-read this book from cover to cover, dilligently working through the examples in a sandbox environment. The book has served to map out the vast Magento infrastructure, so now I understand the scope of the knowledge I need to master, and know the language to use when searching Google and the Magento forums. I commend Allan for doing such a good job on such a difficult task.