Question

I'm rather new to Magento and read in this article that it is possible to configure the base_url values in app/etc/local.xml. Would be nice to have this functionality for running multiple environments, for which Magento doesn't seem to offer a lot of possibilities out of the box (correct me if I'm wrong here, though).

Am I assuming correctly that the values for base_url in local.xml will take precedence over the config values in the database?

What other database config values would you be able to override this way? Not finding a lot of documentation on this...

<config>
    <global>
    <!-- ... -->
    </global>
    <stores>
        <default>
            <web>
                <unsecure>
                    <base_url>http://beispiel.tld/shop/</base_url>
                </unsecure>
        </default>
        <admin>
            <web>
                <unsecure>
                    <base_url>https://beispiel.tld/shop/</base_url>
                </unsecure>
        </admin>
    </stores>
</config>
Was it helpful?

Solution

the order the config files are loaded is this (see Mage_Core_Model_Config::init):

  • every xml file from app/etc/
  • every xml file from app/etc/modules
  • every config.xml of the enabled modules
  • database.

Every lower lever overrides values from upper levels.
this means that what's in the database overrides anything else (if applicable). so the xml you provided works as long as you don't have in the db in the table core_config_data an entry with the path = 'web/unsecure/base_url' and scope = 'stores' and scope_id the id of the store view with the code default.

To summarize and answer your question...

Am I assuming correctly that the values for base_url in local.xml will take precedence over the config values in the database?

Your assumption is incorrect. Database overrides files configuration, but you can still have base urls in xml config files as long as you don't save a value for the same path in the db.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top