I created a module with an observer for the sales module with event hook ‘sales_order_shipment_save_after’ ,
My module has the following files
there are four fields in the modules admin configuration fields I want to get those saved data in the Observer class.
using $this->getConfigData(’password’); gives a
Call to undefined method
error Any suggestions?
In Magento 2, configuration data is stored to core_config_data database table. The easiest way to get a configuration value from there, is using the following code snippet. It's the most closest alternative to construction, which we had used in Magento 1: Mage::getStoreConfig('section/group/field').
In order to fetch system store configuration values by scope level on store or website, you will be required to use ScopeConfigInterface with getValue() method. The first argument sectionId/groupId/fieldId is from your etc/adminhtml/system. xml file. The second argument will be the scope value.
To get DB config file go to:/<Magento Install Dir>/app/etc/local.
Magento uses a static method on the global Mage
application object to get configuration values
$config = Mage::getStoreConfig('section_name/group/field'); //value
$config = Mage::getStoreConfig('section_name/group'); //array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With