Magento: How can I migrate configuration changes from development to production environment?

后端 未结 2 558
灰色年华
灰色年华 2021-01-02 19:14

We are actively developing modules and when we push the changes to our production site, there are usually several configuration changes we need to make. Would be nice to aut

相关标签:
2条回答
  • 2021-01-02 19:33

    Make the changes as part of a an install or upgrade script in your module's "sql" directory. In your module's "config.xml" file increment the version number of every matching change and also remember to fill in the <config><global><resources><MODULE_setup><setup> node.

    Because the script is run within the context of Magento you have access to all the normal functionality too, updates don't have to be in the form of SQL commands.

    0 讨论(0)
  • 2021-01-02 19:49

    Not sure if it is still actual, but if you mean changes to system -> config, then it is much more better to use such config.xml nodes instead of writing database upgrade.

    Magneto processes core_config_data table into global XML structure, so you may just change XML structure without using db table for making changes to system configuration.

    Here is small example:

    <config>
       <stores>
           <french>
              <design>
                 <theme>
                     <default>french</default>
                 <theme>
              </design>
           </french>
       </stores>
       <websites>
           <base>
              <design>
                 <theme>
                     <default>english</default>
                 <theme>
              </design>
           </base>
       </websites>
    </config>
    

    In this example one configuration field is changed for two scopes in Magento. It is definition of current theme depending on current website and store.

    So <stores /> node contains configuration values for a particular store. Where each child element is named with store code and contains configuration data in nested view. And <website /> node contains configuration values for a particular website. Where each child element is named with website code and contains configuration data in nested view as well.

    Also there is available <default /> node for configuration values in global scope. But it will be overridden by <stores /> and <websites /> if a particular value is for a scope.

    I am making changes to configuration only via config.xml because deploying the project is much easier when you just need to install it via Magento installer without doing changes in "System -> Config".

    0 讨论(0)
提交回复
热议问题