cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.x Best Practices and Conventions

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

 

  1. Do not modify the Magento core: app/code/core
    core-2.png
    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.

  2. Avoid rewriting classes
    local.png

  3. If you rewrite a class, then annotate the changes you made to the core file
    comment.png

  4. Avoid implementing a lot of observers
    observer.png

  5. Keep a small number of shopping cart and catalog price rules
    shopping-cart.png

  6. Remember setting magento in Developer Mode to develop
    setdevelopermode.png

  7. Develop with the display_errors setting enabled and E_NOTICE turned on
    ini-set.png

  8. Always turn off the cache in your local machine to avoid losing time
    Screen Shot 2016-10-14 at 10.47.24 AM.png

  9. Document your classes and methods using PHPDoc comments
    docs.png

  10. Limit the usage of PHP in the front-end
    frontend.png

  11. Do not use direct SQL queries to connect to the database, use models instead
    sql.png

  12. Follow Magento naming conventions for classes, methods and files
    1. Methods and variable names should use camelCase
    2. Indexed arrays should use snake_case keys
    3. PHP variable names in the front-end should start with $_ (underscore after $ sign)

Front-end

 

  1. Don't use inline CSS in the front-end

  2. You can use tables, but only if you want to present tabular data

  3. Use image sprites to load icons in your theme

 

 

 

If my answer was useful, please give "Kudos" to this post.
If my answer helps you to resolve the problem, click on "Accept as Solution".
1 REPLY

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 Smiley Happy