Magento – Setting a default value for a config defined value

administrationconfigurationmodule

How can I assign a default value to a config value, which i am defining in a system.xml file? Currently it defaults to 'no', but i want it to default to 'yes'.

Here is my current definition code:

<catalog>
            <groups>
                <my_val>
                    <label>My Label</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>160</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <my_inner_val translate='label comment'>
                            <label>Enable seperate cart items</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <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>
                        </my_inner_val>
                    </fields>
                </my_val>
            </groups>
        </catalog>

Best Answer

You can easily add default values for all configuration settings in your config.xml:

<config>
    <default>
        <cms>
            <wysiwyg>
                <enabled>0</enabled>
            </wysiwyg>
        </cms>
    </default>
</config>

At the moment I'm unable to map your system.xml setting name to the node in the config.xml

I would say it is: catalog/my_val/my_inner_val, means:

<config>
    <default>
        <catalog>
            <my_val>
                <my_inner_val>1</my_inner_val>
            </my_val>
        </catalog>
    </default>
</config>

Small tip in the end: Be careful with the int settings. Sometimes magento uses 1 and 2 for yes/no, on/off, etc.