Creating Custom Configuration Options in Magento Admin

As a Magento developer you frequently encounter the Configuration page of Magento admin backend. But have you ever noticed how these configuration pages are created and where are those configuration options saved? If not don’t worry, today I will tell you how to create an admin configuration page for you custom module. You might wonder that their is no ‘.phtml‘ involved in this configuration page. Shocked! Its ok, we have to play only with the xmls to create this functionality. So now lets start the development.


Open your appcodelocal<Namespace><module>etcsystem.xml
If file is not there, create one as stated below.

<?xml version="1.0" ?>
<config>
<tabs>
<mynew_tab module="<module>" translate="label">
<label>Custom Configuration</label>
<sort_order>100</sort_order>
</mynew_tab>
</tabs>
</config>

These lines will create a new tab in the left hand menu of the configuration page.

Now add following lines to the file:

<sections>
<customconfig module="<module>" translate="label">
<label>Configuration</label> <!-- Name of the submenu in the 'Custom Configuration' tab -->
<sort_order>200</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website> <!-- Whether to show the options on website page -->
<show_in_store>1</show_in_store> <!-- Whether to show the options on store page -->
<tab>mynew_tab</tab>
</customconfig>
</sections>

These lines will add a new submenu to our configuration tab.

Now add following lines to it:

<sections>
<customconfig module="<module>" translate="label">
.....
<groups> <!-- It will add a new group of options on the configuration page -->
<custom_group translate="label"> <!-- Name of the option group -->
<label>My Custom Configurations</label>
<comment>This is example of custom configuration.</comment>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</custom_group>
</groups>
</customconfig>
<sections>

Now write these lines:

<sections>
<customconfig module="<module>" translate="label">
.....
<groups>
<custom_group translate="label">
.....
<fields> <!-- This section will add new options to our group -->
<custom_email translate="label tooltip comment"> <!-- New option created here -->
<label>Is Enabled</label> <!-- Text to be displayed-->
<frontend_type>select</frontend_type> <!-- Input type of option -->
<source_model>adminhtml/system_config_source_yesno</source_model> <!-- Predefined model in core -->
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Enable this module</comment> <!-- Help text for the option -->
</custom_enabled>
<custom_name translate="label tooltip comment">
<label>Sender Email</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Email address of the user.</comment>
</custom_name>
</fields>
</custom_group>
</groups>
</customconfig>
</sections>

Now the complete code may look like this:

<?xml version="1.0" ?>
<config>
<tabs>
<mynew_tab module="fancyfeedback" translate="label">
<label>Custom Configuration</label>
<sort_order>100</sort_order>
</mynew_tab>
</tabs>
<sections>
<customconfig module="fancyfeedback" translate="label">
<label>Configuration</label>
<sort_order>200</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<tab>mynew_tab</tab>
<groups>
<custom_group translate="label">
<label>My Custom Configurations</label>
<comment>This is example of custom configuration.</comment>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<custom_enabled translate="label tooltip comment">
<label>Is Enabled</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Enable this module.</comment>
</custom_enabled>
<custom_email translate="label tooltip comment">
<label>Sender Email</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Email address of the user.</comment>
</custom_email>
</fields>
</custom_group>
</groups>
</customconfig>
</sections>
</config>

But when you try to access this page at this time it may show you ‘Access Denied’ error. To remove this error open appcodelocal<Namespace><module>etcadminhtml.xml and write following lines:

<?xml version="1.0" ?>
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<customconfig translate="title" module="fancyfeedback">
<title>Custom Configuration</title>
<sort_order>100</sort_order>
</customconfig>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>

Now logout from the admin section and login again. This is important to access this new configuration page otherwise ‘Access Denied’ error will continue to persist.
This is all to add new configuration page to your admin page. But now you may need to access the options that you just saved with your configuration page. To access them write:

Mage::getStoreConfig('customconfig/custom_group/custom_email');/*name of section, name of group, name of option*/

In some cases you may need to set a default value of the options. Don’t worry, we have a solution for that also. Open appcodelocal<Namespace><module>etcconfig.xml and add following code:

<default>
<customconfig>
<custom_group>
<custom_enabled>1</custom_enabled> <!-- Enabled by default-->
<custom_email>bhardwajsonheight@gmail.com</custom_email> <!-- set default email address -->
</custom_group>
</customconfig>
</default>

Written by Arvind Bhardwaj

Arvind is a certified Magento 2 expert with more than 10 years of industry-wide experience.

Website: http://www.webspeaks.in/

35 thoughts on “Creating Custom Configuration Options in Magento Admin

  1. I am very glad with your blog. It’s really very interesting post full of valuable information very well written by u. The key part of this post is its descriptive way to define anything. I liked it with my heart. This post is a excellent example of such kind of thread.
    Escorts in Gurgaon

  2. This is very attention-grabbing, You’re an excessively professional blogger. I have joined your feed and look forward to in the hunt for extra of your excellent post. Additionally, I have shared your web site in my social networks. escorts in delhi

  3. Asalamualaikum sir i have done as u said its shown also + i have changed the module name accordingly but when i changed the value of “is enabled” to no the module still shows at front end ????

  4. Asalamualikum

    sir i have done as u said . now its shoeing at the admin side. and i have also changed the module names accordingly but when i change the value of “is enabled” to no it still shows the module at the front end ???

  5. Arvind

    many thnx for this very informative post
    i find it very informative
    i am very inspired to use this very informative post to write better for magento

    best

    Raj Patel

  6. I use this for create custom configuration options of my website and believe it this is great tutorial for me. I have learn so many things from that. Giving thanks to you for sharing such an wonderful piece of knowledge.

  7. Hi,
    Your tutorials are simply awesome…
    But this one is not working for me.. i want to create a theme options page for the site. so i used the module name “Themeoptions” and my namespace is “Acodez”. using capitalize text in xml file makes any issue??? since my module name is in Capitalize, i used it.. is that the reason?
    i logout and login site many times..also tried clear cache, refreshing index management etc.but its not working.. ๐Ÿ™

    Please reply me..
    Lots of Thanks in advance ๐Ÿ™‚

    1. Hi,
      Its hard to guess the exact reason without having a look at the code.
      But yes, Linux is case sensitive. If you are on windows, that should not be a problem.

      Thanks.

    2. Hi,
      Thanks for your reply.. i deleted all my files and created a new module…this one works for me.. i have no idea abt the issue. But now its working fine.. ๐Ÿ˜›
      i guess its something with the spelling or something.. ๐Ÿ˜›
      anway thanks for your tutorial.. ๐Ÿ™‚

  8. Hi,
    Your tutorials are just awesome. For a beginner like me, this site is very useful.
    But this one is not working for me. Newly created configuration menus, sections etc are not displaying in the backend. I want to create a theme options page for this site. for that i have created a module called “Themeoptions” . since i used the capitalized name, i have used the same name for “” in the code. is that the reason for this issue??
    please reply me..

    A Lots Of Thanks In Advance ๐Ÿ™‚

Comments are closed.