- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016
07:15 AM
10-14-2016
07:15 AM
Magento 1.x Best Practices and Conventions
Hi everyone,
I would like to share with you the best practices and conventions for Magento 1 that I've been implementing for the last 7 years.
I will be editing this answer with more and more information, and I would like to hear more about your best practices and conventions.
Based on your participation on this topic, I will edit this post in the topic and I will add your best practices as well, so we can use the first post as a "wiki" and improve it with the collaboration of everyone in the forum.
Back-end
- Do not modify the Magento core: app/code/core
This is the #1 rule when it comes to customizing Magento. To be specific, the files from the app/code/core folder should never be modified to ensure the stability and upgradability of the Magento store. - Avoid rewriting classes
- If you rewrite a class, then annotate the changes you made to the core file
- Avoid implementing a lot of observers
- Keep a small number of shopping cart and catalog price rules
- Remember setting magento in Developer Mode to develop
- Develop with the display_errors setting enabled and E_NOTICE turned on
- Always turn off the cache in your local machine to avoid losing time
- Document your classes and methods using PHPDoc comments
- Limit the usage of PHP in the front-end
- Do not use direct SQL queries to connect to the database, use models instead
- Follow Magento naming conventions for classes, methods and files
- Methods and variable names should use camelCase
- Indexed arrays should use snake_case keys
- PHP variable names in the front-end should start with $_ (underscore after $ sign)
Front-end
- Don't use inline CSS in the front-end
- You can use tables, but only if you want to present tabular data
- Use image sprites to load icons in your theme
Welcome to the Magento Forums. Remember to introduce yourself and read the Magento Forums Guidelines.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2016
09:49 PM
10-24-2016
09:49 PM
Re: Magento 1.x Best Practices and Conventions
Agreed post..!!! related to the Magento 1.x best practices and conventions.
Thanks for sharing the detail and make us updated