Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get magento module config data in Observer

Tags:

magento

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

  1. Company/Modulename/etc/config.xml
  2. Company/Modulename/etc/system.xml
  3. Company/Modulename/Model/Observer.php

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?

like image 650
Sreejith Sasidharan Avatar asked Jul 09 '10 09:07

Sreejith Sasidharan


People also ask

How can I get config data in Magento 2?

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').

How can you fetch a system configuration value programmatically?

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.

Where is Magento config file?

To get DB config file go to:/<Magento Install Dir>/app/etc/local.


1 Answers

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
like image 174
Alan Storm Avatar answered Oct 11 '22 06:10

Alan Storm