Archive for June 24th, 2009

Choosing the lesser evil, or why I have a love/hate relationship with Magento

Wednesday, June 24th, 2009

When looking at Open Source Shopping Cart options, the landscape can get confusing. I generally end up recommending Magento eCommerce. As @ashooner put it on Twitter, Magento is the 800lb gorilla in the room. It can do or be made to do jsut about anything you need. But it’s a gorrilla. And we all know how Planet of the Apes turned out.

I’ll admit that my experience with osCommerce and ZenCart is limited. In the cases where I was required to work with them, I was stepping into an orphaned project and had to pick up where another developer had left off. It was hateful. The “design” of the back-end made me embarrassed to hand it over to the client, and the client was generally extremely confused as to how to work with the cart once they had it. I did the best I could with it, but it was far from fun. (I often say that ZenCart totally harshes my Zen.)

So I started researching, and I attended a wonderful little talk about the Magento community by one Paul Reinheimer during PHP Appalacia. I decided to give it a try on my next project, and I was immediately impressed with the look of the Magento product, the clean interface (back- and front-end). Let’s face it, most clients are very visually oriented, at least initially, and this looked professional. I’ve since implemented this cart a number of times, some for realz and some for testing. Some were pretty much out of the box, others were heavily modified in some way. I’ve built a couple of simple modules (add-ons) and am in the process of building a more complex one.

Starting from the top: Setup is easy, once you are sure you have all the prerequisites on your server. Shared environments can be tricky, and it’s it’s good to have root in this situation, because the downloader (my preferred method of installation after trying the various options) needs the entire directory to be open to the world (chmod 777). I’m not real comfortable with leaving all of my files world open, so I usually open them, do the install or upgrade, and close them back down. If you are running under suexec, this is a bit simpler, but still can be tricky if you haven’t set the ownership permissions correctly. After all this server stuff is settled though, setup is push a button, wait, input some parameters and push another button and you are golden.

I don’t recommend installing the “demo database” unless you are just testing things out. Start with a clean database. OH! And if you plan to do a development machine setup and then migrate to a production server, be prepared: just doing a mySQL dump will give you some pretty ugly results. Be sure to follow the process here.

Adding existing modules, themes, etc. Is pretty simple, but often requires more steps than you would initially expect. You might have to set the new template as the default then go through existing pages/catalog entries and make sure they haven’t been custom defaulted to the old template, for example. It’s very handy to have caching OFF for this part of the setup, as it makes it really tricky when you are being served a cached document and going “BUT I CHANGED THAT!!!”.

If you have a background in themeing for other carts, WordPress, etc. forget everything you know. Magento themes work in an entirely different manner and really take some getting used to. I think this is what turns most people off when they start working with it. PERSEVERE, because once you wrap your head around the way that the XML defined template structure works, you will probably love it. But first, you will hate it a lot. (This is where my love hate relationship comes from. I always have to resettle my head into Magento space when I’ve been away from it for a while.) The flexibility here is amazing, especially since once you understand the XML structure, you can use it to redefine layout on any individual page, set of pages, etc. through the browser accessible back-end!

Building modules is pretty straight up Zend school of design. If you are familiar with the Zend framework, the Mage framework shouldn’t cause you much trouble. If you aren’t all that familiar with the Zend framework (I wasn’t when I started with Magento) Mage can help you get a foot in that door. This part is really for developers, not Web Designers. You need to know more PHP than “include()” and “echo()”.

Overall, the back-end is easy to use, once it is understood. Before I meet with my client for training, I usually backup anything I’ve done with the database. Then I walk my client through each section in the back-end and encourage them to play around and try new things, assuring them that everything they do will be erased after our training. It is extremely robust and can scare some clients. I tell them to focus on the catalog and orders sections and leave the rest to me. As they become more confident, they will often start trying bits in the other sections.

I don’t think that Magento is one of those “free” programs that anyone can download, install, and configure appropriately, but I do think that it is a good option for most end-users who have access to a qualified developer to set it up and walk them through it. There is a frustrating learning curve, but like most good learning curves, it is worth the climb. The community is reasonably helpful, and rather passionate. Of course, Mad Science Dept works with other carts on request, and if the client has only one or two items to sell, we may even write up a very simple tiny cart instead of using one of the very robust Open Source or Commercial options out there.