Architect Magento | Tech Blogger | Magento Trainer
Mohamed Abbas | Architect Magento | Tech Blogger | Magento Trainer
To add custom Magento 2 system configuration fields to the backend, enabling store administrators to adjust specific module settings, you’ll need to use a system.xml file in your module’s etc/adminhtml directory. This setup is somewhat similar to Magento 1, but there are key differences.
Adding custom system configuration fields is especially relevant if:
These configuration values are stored in the core_config_data table, similar to Magento 1.
Example: FTP Connection Fields
To illustrate, consider adding fields that allow administrators to input FTP details. You might create fields for:
These fields are necessary to enable the module to retrieve files from an external FTP server.
Step 1: Access Control List (ACL)
To control access, create an acl.xml file in the etc folder of your module and add a role resource for your module’s system configuration. Here’s an example structure:
Step 2: Define System Configuration Fields in system.xml
In the system.xml file, create a new tab, section, and group for your fields. Here’s an example structure:
custom_tab
Abbas_Acl::config
Each field requires a label and several attributes:
text
for standard input, password
for secure entries)By setting up system configuration fields in this way, you enable easy configuration management for administrators and modular control over your Magento 2 setup.
Technical Lead | Magento Architect