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
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
2
Answers
Need to create config.xml in etc folder of module and we can configure default value as in below example
to set the default value on store level need to change "storeCode" otherwise we can use "default"
Yes, you can set the default value of custom field. For this create a below file in your module folder.
and add below code:
The sectionId/groupId/fieldId has to match the structure in the system.xml file.
Clear cache and check the output.