Manage Variable Configuaration in Magento

Suppose we want to manage any API key or any variable in magento .

We will see here how to manage any configurable variable from magento admin and how we can use these configurable variable in frontend section in any controller or model .

Let we want to Manage Twitter Oauth Consumer key and Consumer secret variable from magento admin. Because these variables are customer related section then we will manage both variables from customer configuration in magento admin.

To make this variables as configurable open App/Code/core/Mage/Customer/etc/system.xml

In this file you will see there is a <groups> tag paste the following code just after <groups> tag


<label>Twitter Application Key</label>






<consument_key translate="label comment">

<label>Twitter Cunsumer Key</label>


<comment>Its the customer key by Twitter for Your Apps.</comment>






<consument_secret translate="label comment">

<label>Twitter Cunsumer Secret</label>


<comment>Its the customer secret by Twitter for Your Apps.</comment>








Now To see editable form goto Magento Admin >> Systme>> Configuration

In the left side you will see under Configuration >> Customers >> Customer Configuration

You will see following sceen

When you save data in it then this data will be saved into Core_config_data table you will see in this table there are two more configuration automatically get added for each of the two values which you have created into system.xml file. Just take path name of your newly added configuration. We will use this path to get this configuration from frontend section .

To get Configuration from frontend section symply write

<em>$consumer_key = Mage::app()->getStore()->getConfig('<strong>customer/twitter_application_key/consument_key</strong>');</em>

Here “customer/twitter_application_key/consument_key” represents our Path taken above.

Related posts:

The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video... Read More about Chandra Shekhar

Latest posts by Chandra Shekhar (see all)