4

If we list the things that make sure the extension has followed the best Magento practices, what it would be? few of them like

  1. Do not use object manager (use constructor dependency instead).
  2. Do not modify data in the observer.

etc

please do contribute to the list.

Thanks.

1

3 Answers 3

2

Actually, Magento have a few articles about "Extension Best practices"

The list may be quite long. I can try to add some general points:

  1. Follow coding standards. We have autotests on git, which run tests on phpcs, phpmd, PHPStan.
  2. Test your extensions properly. Write product quality auto tests like UnitTest, MFTF, Integration.
  3. Follow SOLID Principles.
  4. Better not to modify core Magento DB tables. Instead, use your own tables and some plugins to join results.
  5. Extension better be compatible with the cache. If an extension has its own Blocks, Pages, Collections with big data, then the extension should use cache.
  6. Try to use only API points while coding. It's kinda safer. It means to call, not a Class, but an Interfaces witch has preference in di.xml. Try not to extend core classes which not for extend.
  7. Do not override globally. Like around plugins without calling parent (closure). Or writing preference on core class (should be only for interfaces).
1
1

Yes, there is some point that we need to take care of during the development.

  1. Do not use object manager (use constructor dependency instead).
  2. Do not modify data in the observer.
  3. Avoid to Use Around Plugin.
  4. Do not use PHP variables like getting, POST, FILE, etc.
  5. Set the proper soft & hard dependencies.
1
  • Thankyou for sharing the knowledge @Dhiren sir Commented Jul 28, 2021 at 8:07
0

1.- Policy no depends on another module or only minimal standard framework

3.- Installer and Uninstaller (tables XML schema,images,config,media etc)

4.- Readme File/Manual for Admin Users in the right place

5.- API Gateway for request external services

6.- Config and Menu Admin in the right place

7.- Health Status for UI/Frontend and Backend for Magento Policy Code and Framework

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.