How to setup system configuration in Magento 2?
Read more here: https://www.envisionecommerce.com/se...n-in-magento-2
Printable View
How to setup system configuration in Magento 2?
Read more here: https://www.envisionecommerce.com/se...n-in-magento-2
First of all, We will need to declare ACL for the config in our extension. After that we are ready to add our extension config file. With system.XML file we will add custom config tab "example tab config" and one group of config field within. And our config section that belongs to this tab (with "<tab>"tag) has only one group of field (<group id="general">) and acl relation ("<resource>"tag):
Try this one, I think its perfect solution of your problems
First of all need to use following file to create it.
1) app/code/Vendor/Helloworld/etc/adminhtml/system.xml
2) app/code/Vendor/Helloworld/etc/acl.xml
This 2 files are important to create system configuration.
In system.xml file
Adding the common content
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
<system>
<!-- Add new Tab -->
<tab id="vendor" translate="label" sortOrder="300">
<label>Vendor Extension</label>
</tab>
<section id="helloworld" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Helloworld</label>
<tab>vendor</tab>
<!-- resource tag name which we have to defined in the acl.xml -->
<resource>Vendor_Helloworld::config_helloworld</resource>
</section>
<group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General Options</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Y esno</source_model>
</field>
</group>
</system>
</config>
In acl.xml file
In the file need to write the below content
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<!-- this resource id we can use in system.xml for section -->
<resource id="Vendor_Helloworld::config_helloworld" title="Helloworld Section" sortOrder="80" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
After that, Clear the magento cache & logout from admin side. Then Login at admin side. In store > Configuration you can see the tab “Vendor Extension”. When you click on this you can see the detail of this.
If you need more info, about this followed below links;-
http://stackoverflow.com/questions/3...-custom-module
https://www.mageplaza.com/magento-2-...magento-2.html
http://www.outsourcing4work.de/en/so...nto-developer/
Magento System configuration is a simple way to store single values required for application functionality. You have developed a Magento extension with multiple functionality. Now the extension is installed and excuting as well. Let us consider a scenerio you want to enable some of available functionality instead of all then what ? How do you configure that ? Here system configuration comes into picture. If you have added a setting for each funcionality than it work like a charm. In this article, we are going to explain how to create a Magento2 system configuration with the different type of fields, validation, resources etc. In Magento2 the global architecture of system configuration is changed but the vision is the same. Add global configuration by website store(group) or store view and use inside your code for enable disable or other choices.
How to add Magento2 system configuration file
So lets start with the Magento2 system configuration file structure. Create a file app/code/Companyname/Modulename/etc/adminhtml/system.xml
Lets us discuss some basic of Magento2 system configuration
Tab: The first thing we need to add a custom “Tab” to the System Configuration. Tabs are left navigation in admin section Stores -> Configuration. The default tabs are General, Catalog, Customers, Sales, Services, and Advanced.
Section: Each Tab has a number of sections. For example, the Advanced tab has (by default) an Admin, System, Advanced, and Developer section. If a Tab is configured with no sections, it won’t show up.
Group: Groups are used to group together different configuration options, and are displayed in the Magento admin with a pop-open widget. For example, in a stock install the Advanced section has a single group named “Disable modules output”.