Magento – custom configuration variable in config.xml

Normally we are managing the system config variable from system -> Configuration, and we are creating the same with system.xml. But we can also set the default for these variable, using module’s config.xml file.

Let’s assume one sample module called “mymodule”. Goto config.xml of mymodule, add the code as bellow

<?xml version="1.0"?>
        <config>
            <modules>
                <Techbandhu_Mymodule>
                    <version>0.0.1</version>
                </Techbandhu_Mymodule>
            </modules>
            <default>
                <mymodule>
                    <default>
                        <show_desc_length>450</show_desc_length>
                    </default>
                </mymodule>
            </default>
      </config>

You can access this value,

$showDescLength = Mage::getStoreConfig('mymodule/default/show_desc_length');
Advertisements

One thought on “Magento – custom configuration variable in config.xml

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s