Magento has an awesome way to manage configuration values. Under Admin>System>Configuration all useful configuration for different module resides. Today I am going to show you how to create a new configuration value in admin and how use them from your code.

For example Lets create 2 fields under configuration, Enable Minimum Production Calculation , a drop down with Yes/No value and another a text input field Minimum Production Cost

Step 1: 

Set path for your configuration field in \app\code\local\Mypackage\Mymodule\etc\Config.xml by create a default node under config.

<?xml version="1.0"?>






	<!-- Create we create config path for cofiguration -->

		<!-- Under checkout/mimimumproduction we create out config paths and their default values -->
				<!-- Config path checkout/mimimumproduction/minimum_production_enabled with defaule value 1 -->
				<!-- Config path checkout/mimimumproduction/minimum_production_cost with defaule value 200 -->


That’s it, now can from your code you can access this config values using Mage::getStoreConfigFlag() and Mage::getStoreConfig like following:-

//return true false based on config settings
Mage::getStoreConfigFlag('checkout/minimumproduction /minimum_production_enabled');
//return 200

But still you are not done.Customer not gonna change these values from XML. You need to give your client a way to set these values from admin panel. So, lets make our hands dirty on admin panel changing 🙂

Step 2:-

Create your configuraion alias node under \app\code\local\Mypackage\Mymodule\etc\system.xml

<?xml version="1.0"?>

        <checkout translate="label" module="checkout">

			<!-- If want to set these config values under youw own module, only then change the following commented fields -->
            <show_in_store>0</show_in_store> -->


				<!-- Create a field group for your config paths -->
                <minimumproduction translate="label">
                    <label>Checkout Minimum Production Cost</label>

					<!-- List your config values here -->

						<!-- This goes for checkout/minimumproduction/minimum_production_enabled -->
						<minimum_production_enabled translate="label">
                            <label>Enable Minimum Production Calculation</label>

						<!-- This goes for checkout/minimumproduction/minimum_production_cost -->
						<minimum_production_cost translate="label">
                            <label>Minimum Production Cost</label>







Ya, now you are done. If you go to Admin>System>Configuration you can see a new field group with name Checkout Minimum Production Cost created, under which you will find your configuration values with default values. You can change your default settings from here.

Have a happy time with Magento 😀 !!!