I was asked by Packt Publishing to review a new book entitled Magento 1.4 Development Cookbook. I was excited for the opportunity to review a recent development book, hoping I might get some new fresh perspectives.
Before I get into the details, I highly recommend avoiding this book. Unless you want a reference of how NOT to develop properly with Magento, do not buy it. Save your money and time and just spend a few hours looking through Magento’s core modules and learn by example. That to me has been the best reference in learning how to develop with Magento.
Why avoid this book
- In the first chapter, the author lists some reasons as to why Magento’s coding conventions are good and make sense, but then go on to say “We are not compelled to follow Magento conventions.” Why would you not!? No reason was given.
- In all their examples having to do with modifying theme files, they only very briefly (a couple paragraphs) suggest making your own theme. Not nearly enough to stress any importance in it. Then, they specifically say they are modifying base/default theme files for all the examples.
- They suggest modifying the existing layout xml files. It is a much better practice to create your own local.xml file (in app/design/frontend/your-package/your-theme/layout/local.xml) and have all of your modifications in there. That way, you have quick and easy access to every change you made without having to wonder what you changed over the course of a project.
- Adding custom CMS templates (which you can select when creating/editing a CMS page): Their suggestion is to modify app/etc/modules/Mage_All.xml and change the codepool for the Mage_Page module from ‘core’ to ‘local’, then move the Mage_Page config.xml file from app/code/core/… to app/code/local/… This, without question, is an amazingly awful idea. To accomplish this functionality, it can easily be done by creating your own module, and not touching any core files.
- Add RSS feed of the last 5 tweets to your site: They failed to suggest writing a module for this. Instead, they have you putting business logic code right within template files. Bad idea.
- Adding an image rotator: Their example basically makes it very difficult for any clients (if you are developing a website for a client) to manage it. I would never go this route for any of my clients.
- Adding jQuery and Lightbox: Their implementations where completely template-based. A module should have been written for both these implementations.
- Adding a Twitter handle to the customer registration: This was one of the worst examples in the book. They have you put all the php to create the custom customer attribute in template files, and then have you edit core files directly.
- Installing Magento without mcrypt: Another one of the worst examples in the book. They have you directly modifying lib/Varien and core files.
- When you finally get to the chapter about creating modules, they have you use a module creator instead of just making one from scratch.
- They suggest putting xml that should be in app/etc/modules in your modules config.xml file.
There are potentially a couple of chapters in this book that could be good (performance optimization and unit testing), but I don’t know enough on those topics to review them well. I’d hesitate to think the authors have you do it properly given the rest of the book, but to be fair I can’t say for sure. Perhaps they are much better with those subjects than actual Magento development.
As a whole though, this book should be avoided. Like the authors said upfront, they had no interest in following Magento’s coding conventions, and it very clearly shows throughout this book. By not following Magento’s conventions, the authors walk you through terrible implementations and concepts, many of which would break if you ever decided to upgrade Magento (because of overriding the base templates and overriding core files). Without question, it is best to follow Magento’s coding conventions, think modular, and never touch core files.