Magento:将基本URL存储在配置文件中 [英] Magento: storing base url in a config file

查看:69
本文介绍了Magento:将基本URL存储在配置文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有多个开发阶段,我想将一些magento配置保存在文件中,而不是保存在数据库中,因此我可以使开发版本和生产版本同步.

Having multiple development stages, I'd like to keep some magento configurations in a file, and not in the database, so i can have my development version and the production version in sync.

因此,我需要将基本URL"(而不是数据库)放在不同的位置,因为我想将其从生产环境导出到开发环境

So i need to put in a different place the "base url", that is not the database, because I'd like to export it from production to development

有可能吗?

推荐答案

可能:

<default>
    <web>
        <unsecure>
            <base_url>https://foo.dev/</base_url>
        </unsecure>
        <secure>
            <base_url>https://foo.dev/</base_url>
        </secure>
    </web>
</default>
<websites>
    <ws_code>
        <web>
            <unsecure>
                <base_url>http://ws.foo.dev/</base_url>
            </unsecure>
            <secure>
                <base_url>https://ws.foo.dev/</base_url>
            </secure>
        </web>            
    </ws_code>
</websites>
<stores>
    <store_code>
        <web>
            <unsecure>
                <base_url>http://store.foo.dev/</base_url>
            </unsecure>
            <secure>
                <base_url>https://store.foo.dev/</base_url>
            </secure>
        </web>            
    </store_code>
</stores>

但是,如果有人在管理员中保存(或保存了)System > Configuration > Web部分,则该范围内的配置文件中的值将不适用.

However if anyone ever saves (or has saved) the System > Configuration > Web section in the admin, the values in your config file for that scope will not apply.

有两种保护您的条目的策略

There are a couple of strategies for protecting your entries

  1. 使用基于文件的配置方法,并禁止通过管理员用户角色访问Web部分(适用于所有用户). 注意事项:您需要在配置中提供所有配置选项.

  1. Use the file-based config approach and disable access to the Web section via admin user roles (for all users). Caveat: you'll need to provide all of the configuration options in your config.

使用安装脚本(PHP)将base_url条目写入core_config_data表,并防止它们被在adminhtml事件区域下为core_config_data_save_before事件配置的观察者覆盖.

Use setup scripts (PHP) to write the base_url entries to the core_config_data table, and protect them from being overwritten via an observer configured under the adminhtml event area for the core_config_data_save_before event.

您还可以将策略2的观察者保护与策略1的基于文件的配置结合起来.

You could also combine the observer protection from strategy #2 with the file-based config from strategy #1.

这篇关于Magento:将基本URL存储在配置文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆