zookal/ harris-street-impex
用于导入和导出配置数据的 Magento n98-magerun 模块。支持层次文件夹结构和不同环境。
Requires
This package is not auto-updated.
Last update: 2020-08-22 07:08:57 UTC
README
导入和导出存储在 core_config_data 表中的 Magento 配置。通过继承处理不同环境。
支持多种格式,如
- CSV
- Json
- LimeSodaXml LimeSoda EnvironmentConfiguration
- Xml
- Yaml
- ASCII 文本文件格式 – ASCII 定界文本 – 非CSV或制表符定界文本
目前,Yaml 导入格式支持最好。CSV 和 JSON 也能正常工作。
导出
$ ./n98-magerun.phar hs:ccd:export --help
Usage:
hs:ccd:export [-m|--format[="..."]] [-a|--hierarchical[="..."]] [-f|--filename[="..."]] [-i|--include[="..."]] [-x|--exclude[="..."]] [-s|--filePerNameSpace[="..."]] [-c|--exclude-default[="..."]]
Options:
--format (-m) Format: yaml, json, csv, xml, limeSodaXml (default: "yaml")
--hierarchical (-a) Create a hierarchical or a flat structure (not all export format supports that). Enable with: y (default: "n")
--filename (-f) File name into which should the export be written. Defaults into var directory.
--include (-i) Path prefix, multiple values can be comma separated; exports only those paths
--includeScope Scope name, multiple values can be comma separated; exports only those scopes
--exclude (-x) Path prefix, multiple values can be comma separated; exports everything except ...
--filePerNameSpace (-s) Export each namespace into its own file. Enable with: y (default: "n")
--exclude-default (-c) Excludes default values (@todo)
--help (-h) Display this help message.
通过 --include
、--includeScope
和 --exclude
三个开关将 SQL 查询通过 AND
添加。
示例
导出 general
和 tax
命名空间的层次 xml
$ ./n98-magerun.phar hs:ccd:export --format=xml --include=general,tax --hierarchical=y
将每个命名空间的配置设置导出到以 test
为前缀的单独文件中
$ ./n98-magerun.phar hs:ccd:export --filePerNameSpace=y --filename=test
Wrote: 12 settings to file test_admin.yaml
Wrote: 118 settings to file test_advanced.yaml
Wrote: 18 settings to file test_bestsellerproductslider.yaml
Wrote: 6 settings to file test_bss.yaml
Wrote: 294 settings to file test_carriers.yaml
Wrote: 61 settings to file test_catalog.yaml
Wrote: 12 settings to file test_cataloginventory.yaml
Wrote: 16 settings to file test_checkout.yaml
...
导入
要导入配置,需要在文件系统中设置特定的文件夹结构。
$ ./n98-magerun.phar hs:ccd:import --help
Usage:
hs:ccd:import [-m|--format[="..."]] [-a|--hierarchical[="..."]] [--base[="..."]] folder environment
Arguments:
folder Import folder name
env Environment name. SubEnvs separated by slash e.g.: development/osx/developer01
Options:
--format (-m) Format: yaml, json, csv, xml, limeSodaXml (default: "yaml")
--hierarchical (-a) Create a hierarchical or a flat structure (not all export format supports that). Enable with: y (default: "n")
--base Base folder name (default: "base")
--help (-h) Display this help message.
--quiet (-q) Do not output any message.
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction (-n) Do not ask any interactive question.
--root-dir Force magento root dir. No auto detection
--skip-config Do not load any custom config.
Yaml 文件格式
# Default scope web/unsecure/base_url: default: 0: 'http://example.com/my-base-url/' # Store view scope -> "Example Store-ID 1" web/unsecure/base_url: stores: 1: 'http://example.com/my-base-url/' # Store view scope -> "Example with store-view code" web/unsecure/base_url: stores: my_store_code: 'http://example.com/another-base-url/' # Delete entry web/unsecure/base_url: stores: my_store_code: !!delete # Run n98-magerun commands commands/run: - sys:store:list - db:query "select * from sales_flat_order"
文件夹设置
例如,为 cyrill 的开发环境导入示例
$ ./n98-magerun.phar hs:ccd:import ./configuration/newCoreConfigData development/cyrill
导入是如何工作的?
在上面的屏幕截图中关注文件夹: configuration/newCoreConfigData
和我们的示例导入命令。
导入器始终期望一个基础文件夹(也可以通过 CLI 选项配置),其中存储所有默认配置选项的 n 文件。它读取所有这些文件并将它们的设置加载到 Magento 中。
在下一步中,导入器加载 development
文件夹中的所有文件,但不递归,并将这些内容加载到 Magento 中。然后跳转到 cyrill
文件夹并加载那里的文件。完成!
输出如下
Processed: ./configuration/newCoreConfigData/base/contacts.yaml with 4 values.
Processed: ./configuration/newCoreConfigData/base/crontab.yaml with 6 values.
Processed: ./configuration/newCoreConfigData/base/currency.yaml with 11 values.
Processed: ./configuration/newCoreConfigData/base/customer.yaml with 33 values.
Processed: ./configuration/newCoreConfigData/base/design.yaml with 40 values.
Processed: ./configuration/newCoreConfigData/base/dev.yaml with 14 values.
Processed: ./configuration/newCoreConfigData/base/general.yaml with 15 values.
Processed: ./configuration/newCoreConfigData/development/test_web.yaml with 36 values.
Processed: ./configuration/newCoreConfigData/development/cyrill/test_web.yaml with 4 values.
你可以自由命名文件夹和文件。
导入期间的文件格式将根据其扩展名自动检测。.yaml
有效,而 .yml
则无效。
转换
从配置创建 .magerun 文件以供以后在服务器上处理非常有用。
$ ./n98-magerun.phar help hs:ccd:convert
Usage:
hs:ccd:convert [-m|--format[="..."]] [-a|--hierarchical[="..."]] [--base[="..."]] [--export-file[="..."]] folder env
Arguments:
folder Import folder name
env Environment name. SubEnvs separated by slash e.g.: development/osx/developer01
Options:
--base Base folder name (default: "base")
--export-file File name in which the n98 commands shoud be written. If empty -> stdout
安装
在您的 composer.json
文件中需要此安装程序
"require": {
…
"zookal/harris-street-impex": "dev-master",
…
}
或者通过modman
$ modman clone git@github.com:Zookal/HarrisStreet-ImpEx.git
许可证
版权
版权所有 © 澳大利亚悉尼 Zookal Pty Ltd
作者
Cyrill at Schumacher dot fm 或 cyrill at zookal dot com