?> November 2023 - Addeos

Monthly Archive 12 November 2023

Magento 2 – Adding Custom Configuration – Quick Tutorial

Welcome to our comprehensive Magento 2 custom configurations guide.

In this tutorial, we'll walk you through the essential steps to seamlessly integrate and manage personalized settings for your e-commerce store. Unlock the full potential of your Magento 2 experience with our expert insights and easy-to-follow instructions.

Follow these steps to integrate your custom configuration effortlessly:

Step 1: Create your custom module

Develop a custom module if you haven't already. This typically involves setting up the necessary files and directories. Check this post for creating your first module : https://www.addeos.com/magento-2-creating-a-magento-module-a-beginners-guide

Step 2: Create system.xml file

Inside your module's etc folder, create a system.xml file. This file will define your custom configuration fields.

Step 3: Define configuration fields

Within system.xml, define your custom configuration fields using XML tags like <section>, <group>, and <field>. Specify field types, labels, and other attributes.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <section id="custom_section" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Custom Section</label>
            <group id="custom_group" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Custom Group</label>
                <field id="custom_field" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Custom Field</label>
                    <comment>Some description for your custom field.</comment>

Step 4: Run setup upgrade command

After defining your configuration, run the setup upgrade command to apply changes:

php bin/magento setup:upgrade

Step 5: Access Configuration in the Admin Panel

Navigate to Stores > Configuration in the Admin Panel. Your custom configuration section and fields should be visible for modification.

Congratulations! You've successfully added custom configuration settings to Magento 2 through your custom module. Adjust these steps according to your specific requirements.