I’ve created a configuration screen for my Magento2 module, on this file (System.xml) I’ve an input text field like following:
<field id="postback_url" type="text"...>
<backend_model>VendornameModulenameModelConfigSourceConfigs<backend_model>
</field>
I need to insert a default value. This value will the BaseUrl + /some-endpoint
How do I insert a default value on my text field?
i’m not quite sure how it can be done in Magento2.x
In magento 1.x I’ve used this:
class myClassName extends Mage_Core_Model_Config_Data{
protected function _afterLoad(){
$this->setValue("my URL goes here");
}
But apparently, it doesn’t work on Magento 2.x
Thank you in advance!
2
Answers
In your modules etc folder create a config.xml file:
To get a dynamic value, for example, to get a dynamic value inside the comment and /comment, you should use something like NamespaceModuleNameModelConfigSourceConfigCommentin the model class and then in class NamespaceModuleNameModelConfigSourceConfigComment.php