Magento’s Core CodeBy Brian Holecko Certified Magento Developer at InteractOne

Preserving Magento’s Core Integrity

Magento’s Core Code is intended to be preserved – not modified – so that upgrades can be completed gracefully and without error. The common procedures for extending the core using observers, overriding functions for blocks, helpers, models, and controllers are often leveraged appropriately.

However, there are a handful of techniques for the front-end that are worthy of discussion and exploration. Often, these are not used owing to controversy over what is actually included in Magento’s core code and what is not.

Here are four important front-end tips for preserving Magento’s core code.

styles.css and other base CSS files
In regard to the skin, styles.css and other base CSS files should be treated like core files. A separate CSS file (local.css or custom.css) should be used to override styles, even if there are many changes to be made to the default styles.

Theme base files
Theme base files should be treated similar to core files in regards to layout files. Too often, layout files are copied over to a custom theme directory for minor edits. These edits should instead be put into a single layout file named local.xml or custom.xml. Any edits made to the layout files after being copied over can be achieved using a custom layout file including removing CSS/JS references and other functions which may not be necessarily obvious how to code.

Template files
Template files sometimes have hooks to add additional content, so instead of copying over a template file, try to create a new block in the layout if possible. Also, it is  best-practice to defer to using CSS to correct templates instead of changing the HTML.

/js/ directory
The /js/ directory should be treated as core as well. Modifying these files are discouraged, however, if it is required, be sure to place them into the skin JS directory instead of the core directory.

With these four tips in mind, you will have a cleaner theme with reduced amounts of core edits.  Your site will be easier to upgrade when necessary and will be closer to standard Magento development best practices.

Concerned that your core code may have been compromised? Contact us to learn more about our Code Review and Maintenance and Support options or call us 513-469-3361