cancel
Showing results for 
Search instead for 
Did you mean: 

set default value in Magento 2.4

set default value in Magento 2.4

Hello

I'm working on Magento 2.4 and I was creating a custom field in system.xml. I want to set the default value of this field as the URL of the store. How can do that?

Thank you

1 REPLY 1

Re: set default value in Magento 2.4

Hello @sqirnasgma7178 

 

Yes, you can create config.xml and stores the default value. Please follow the steps below:

 

  • Create config.xml file (path: /app/code/Vendor/Module/etc/)
    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
        <default>
            <section_id>
                <group_id>
                    <field_id>ADD_URL_HERE</field_id>
                </group_id>
            </section_id>
        </default>
    </config>
    Please replace section_id, group_id & field_id as per your module system.xml file. (system.xml file path /app/code/Vendor/Module/etc/adminhtml/system.xml)
  • Please run the following commands:
    • php bin/magento s:s:d -f
    • php bin/magento c:f

 

If you find our reply helpful, please give us kudos.

 

A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.

 

WebDesk Solution Support Team

Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789


Location: 150 King St. W. Toronto, ON M5H 1J9