layout | group | subgroup | title | menu_title | menu_order | version | github_link |
---|---|---|---|---|---|---|---|
default |
ext-best-practices |
02_Extension-Coding |
Coding FAQ |
Coding FAQ |
1000 |
2.0 |
ext-best-practices/extension-coding/coding-faq.md |
This page is a compilation of frequently asked coding questions by the Magento Community.
- SOLID principles{:target="_blank"} - The essential principles needed to create maintainable and extendible code.
- PHP{:target="_blank"} - This is the programming language used for developing Magento 2 code.
- HTML{:target="_blank"}, CSS{:target="_blank"}, and JavaScript{:target="_blank"} - Languages used for frontend development.
- Magento architecture - Developers should be familiar with the architectural concepts used in Magento such as the Model-View-Controller{:target="_blank"} pattern and the Command Query Responsibility Segregation{:target="_blank"} principle.
- Dependency Injection - An important design pattern used in Magento to handle dependencies across classes and modules.
In Magento 2, how can my extension distinguish between the Community Edition and the Enterprise Edition?
The correct edition can be obtained through \Magento\Framework\App\ProductMetadataInterface::getEdition
.
In Magento CE that interface maps to the concrete implementation Magento\Framework\AppInterface\ProductMetadata
.
However, in Magento EE, the Enterprise module will override that mapping and the interface will be implemented by \Magento\Enterprise\Model\ProductMetadata
.
Just relying on the interface through dependency injection will get you the right class, and calling "getEdition" will return the right answer.
Use the <Module Directory>/etc/adminhtml/menu.xml
file to configure from where on the Admin your extension is accessible.