Fork me on GitHub

Magento: The Right Way

Introduction

This isn’t a tutorial. This is a (debatable) list of things I think you should be doing as a Magento Developer. This is a living document and would love some recommendations on content as well as another set of eyes over the content.

As you might have guessed, this site borrows shamelessly from the brilliant PHP: The Right Way.

Themes

The theme that accompanies your store will invariably be the biggest component of your build and so it’s important to build it correctly.

Blocks

Back to top

Templates

Back to top

Layouts

Back to top

Extensions

All modifications to the core functionality of Magento should be done by way of Magento extensions.

A strong incentive for migrating to Magento is the number of extensions on Magento Connect. Unlike Apple’s App Store, there is no code review nor quality control procedure to listings. These extensions should reside within the community code pool.

When building a Magento store, it is likely that you will have to add custom code in order to:

These changes should be made in a modular fashion (loosely coupled and high cohesion) within the local code pool.

Do not edit the core code pool.

Third Party Extensions

Back to top

Observers

The best way to add code to Magento is to make use of the events system. This allows custom code to be fired upon receipt of an event without having to rewrite models or blocks.

Developing with observers means that the code is more independent and less likely to conflict with other extensions.

Back to top

Admin Area

Back to top

Debugging

There are plenty of methods to debug Magento issues. Most problems can be resolved with a fundamental understanding of how components fit together, along with a good idea of where to start looking. For everything else there’s xdebug.

The Varien_Object

You can inspect the contents of a Varien_Object with the ->debug() method.

Back to top

Logging

Back to top

Database Queries

Back to top

Performance

Shops should be fast. Page loading times have a known direct impact on conversion rates.

Frontend

Most of the traditional frontend developer techniques to improve your website’s speed apply to Magento - it’s a web application after all.

Back to top

Backend

There are few basic methods to speed up Magento installation, a number of which are described in an official Magento whitepaper on the topic.

Back to top

Development Tools

There are a number of tools that have emerged to make your life as a Magento Developer easier.

Testing

Testing Magento can be difficult, but there are tools out there to make it easier.