Hello to Amasty blog readers!

We hope your preparation for Magento 2 certification goes well.

Good news, by the way, another of our team developers Mihail has prepared the answer to the 1.3 topic from the study guide. So, enjoy studying.

Magento 2 configuration files [brief overview]

Magento 2 configuration is divided into separate configuration files. Each of the files (that are also called configuration types) is responsible for its own task and located in the relevant directory.

The configuration files allow you to easily customize a component and are loaded only when Magento accesses the configuration directly.

Read here to learn more about configuration files loading.

Thus, to change the behavior of your module you need to know how to utilize the configuration files.

Visibility areas

Magento 2 has several visibility areas:

  1. Primary configuration (app/etc/di.xml)
  2. Global configurations from modules (<your component base dir>/<vendorname>/<component-type>-<component-name>/etc/*.xml)
  3. Area-specific configuration from modules (<your component base dir>/<vendorname>/<component-type>-<component-name>/etc/<area>/*.xml)

In this, number (1) directory is used for bootstrapping Magento; number (2) directory is responsible for collecting and merging certain configuration files from all modules; and number (3) directory gathers and merges configuration files from all modules into the global configuration.

Where:

  • <your component base dir> is the base directory in which your component is located;
  • <vendorname> is the component developer (vendor) name;
  • <component-type> is:
    module-
    theme-
    language-
  • <area> is:
    frontend (for store frontend)
    adminhtml (for store backend)
    webapi_rest (REST API)
    webapi_soap (SOAP API)

Configuration files and their utilization

Here is the tree of configuration files:

config-files-tree-magento-2-certification

Below we will take a look at each of the files and their intended use.

config.xml

This configuration file contains default values for configuration:

config-xml-file-magento2-certification

module.xml

The configuration file stores the name and version of the module, as well as its dependencies on other modules:

module-xml-file-magento2-certification

acl.xml

The configuration file can be used for admin users access setting up by utilizing roles:

acl-xml-file-magento2-certification

di.xml

The file can be utilized for dependencies injection. It is required for creating plugins and virtual types, as well as for declaring dependencies between classes.

Learn more from here:

di-xml-file-magento2-certification

email_templates.xml

The configuration file contains email templates:

email-templates-xml-file-magento2-certification

events.xml

The file contains reactions of the observers to the events they are set to watch for:

events-xml-file-magento2-certification

webapi.xml

The file stores API configuration:

webapi-xml-file-magento2-certification

sections.xml

The file is utilized to define actions which trigger update section:

section-xml-file-magento2-certification

routes.xml

The configuration file is utilized for routing setup:

routes-xml-file-magento2-certification

system.xml

The file can be used for creating settings in Stores>Configuration:

system-xml-file-magento2-certification

menu.xml

The configuration file is utilized for adding tabs to the Admin Panel:

menu-xml-file-magento2-certification

crontab.xml

The file is used for creating cron tasks:

crontab-xml-file-magento2-certification

view.xml

The configuration file stores dynamic information about themes. E.g.: information about the sizes of product images:

theme-frontend-blank-file-magento2-certification

That’s all for today. The short notes have been gathered to put you in the way of things. If you need to dig a little deeper, consult the official Magento DevDocs.

We hope this was of service. Share your opinion and drop us a line if you still have questions on the topic.

P.S. Stay tuned and check our next posts in preparation for Magento 2 certification exam!