How to Set Per-Website Defaults in config.xml

configuration

With custom modules I prefer to put system config settings in config.xml (the default settings part). This makes it easier when I push code from my local machine to a dev/staging/live environment as I don't need to go into admin and re-enter settings. There are other benefits too – it can be quicker to do things in a text editor and you can always have a sensible default if there is something in the config.xml for that.

I would like to do this for a multi-website Magento store that has different shipping prices for different websites (and store views). At the moment my stores are called 'euro', 'usd' and 'gbp'. The 'euro' view takes the admin defaults with no over-ride at the website level whereas 'gbp' and 'usd' views are with the over-ride at website level.

    ...
    <default>
    <carriers>
        <my_courier>
            <stuff_goes_here_such_as_price/>
            <price>15.00</price>
            ...
        </my_courier>
    </carriers>
</default>

Best Answer

You can add this using the <stores> node in your config.xml as follows.

<stores>
    <store_code>

You can also do this on website level with the <websites> node in your config.xml as follows.

<websites>
    <website_code>

The only examples of this in the core code is in the admin side because these are the only websites or stores that are guaranteed to be in the system. Check out app/code/core/Mage/Adminhtml/etc/config.xml for an example.

<websites>
    <admin>
        <web>
            <routers>
                <frontend>
                    <disabled>true</disabled>
                </frontend>
            </routers>
            <default>
                <no_route>admin/index/noRoute</no_route>
            </default>
        </web>
    </admin>
</websites>
Related Topic