magento2数据迁移指南-配置迁移
《Magento2.X企业级开发实战》
配置迁移
安装数据迁移工具后,以下目录包含映射和配置文件:
- Magento 开源:
<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/opensource-to-opensource
:从 Magento Open Source 1 迁移到 Magento Open Source 2 的配置和脚本
- Adobe Commerce:
<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/opensource-to-commerce
:从 Magento Open Source 1 迁移到 Adobe Commerce 2 的配置和脚本<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/commerce-to-commerce
:用于从 Adobe Commerce 1 迁移到 Adobe Commerce 2 的配置和脚本
前面的目录包含每个受支持版本的子目录。
配置迁移
有两种方法可以配置数据迁移工具:
- 在单独的模块中配置数据迁移工具(推荐)
- 更改目录中的数据迁移工具配置
<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/
。
要使用源代码管理来管理迁移配置并将其用于部署,您必须创建一个单独的模块。如果您打算只在本地运行数据迁移工具,您可以<your Magento 2 install dir>/vendor/magento/data-migration-tool/
直接编辑目录中的文件。
在单独的模块中配置迁移
在迁移任何数据之前,您必须创建一个 Magento 2 模块。创建一个新的 Magento 2 模块。
<your Magento 2 install dir>/app/code/Vendor/Migration/composer.json
{ "name": "vendor/migration", "description": "Providing config for migration", "config": { "sort-packages": true }, "require": { "magento/framework": "*", "magento/data-migration-tool": "*" }, "type": "magento2-module", "autoload": { "files": [ "registration.php" ], "psr-4": { "Vendor\\Migration\\": "" } }, "version": "1.0.0" }
<your Magento 2 install dir>/app/code/Vendor/Migration/registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Vendor_Migration', __DIR__ );
<your Magento 2 install dir>/app/code/Vendor/Migration/etc/module.xml
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Vendor_Migration" setup_version="1.0.0"> <sequence> <module name="Magento_DataMigrationTool"/> </sequence> </module> </config>
- 将
config.xml.dist
配置文件从数据迁移工具 (<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/<migration edition>/<ce or version>
)的相应目录复制到<your Magento 2 install dir>/app/code/Vendor/Migration/etc/<migration edition>/<ce or version>/config.xml
文件中。例如,如果您迁移Magento 1.9.3.6 Community Edition
到Magento 2 Open Source
:cd <your Magento 2 install dir> cp vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.6/config.xml.dist app/code/Vendor/Migration/etc/opensource-to-opensource/1.9.3.6/config.xml
- 在该
config.xml
文件中,您必须设置对 M1 和 M2 数据库和加密密钥的访问详细信息。 - 如果您的 M1 商店有自定义更改,您应该将其余的配置文件映射到您的 Magento 1 商店自定义。请参阅使用配置和映射文件。
在vendor
文件夹中配置迁移
在迁移任何数据之前,您必须config.xml
从提供的示例创建一个配置文件。
有两种可能的方法来配置数据迁移工具以进行迁移:
- 以文件系统所有者的身份登录或切换到您的 Magento 服务器。
- 切换到以下目录:
<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/<migration edition>/<ce or version>
- 输入以下命令以
config.xml
从提供的示例创建一个:cp config.xml.dist config.xml
config.xml
在文本编辑器中打开。- config.xml 文件至少必须包含对 M1 和 M2 数据库和加密密钥的访问详细信息。
1 2 3 4 5 6 7 8 9 <source> <database host="127.0.0.1" name="magento1" user="root"/> </source> <destination> <database host="127.0.0.1" name="magento2" user="root"/> </destination> <options> <crypt_key /> </options>
这 标签必须包含一个值。你可以在里面找到 标记,位于 Magento 1 实例的 app/etc/local.xml 文件中。可选参数:- 数据库用户密码:
password=<password>
- 数据库自定义端口:
port=<port>
- 表前缀:
<source_prefix>
,<dest_prefix>
root
带有密码,pass
并且您magento1
在 Magento 1 数据库中使用前缀,请在以下内容中使用config.xml
:1 2 3 4 5 6 7 8 9 10 <source> <database host="127.0.0.1" name="magento1" user="root" password="pass"/> </source> <destination> <database host="127.0.0.1" name="magento2" user="root" password="pass"/> </destination> <options> <source_prefix>magento1</source_prefix> <crypt_key>f3e25abe619dae2387df9fs594f01985</crypt_key> </options>
- 数据库用户密码:
完成后,保存更改config.xml
并退出文本编辑器。
使用 TLS 协议连接
您还可以使用 TLS 协议(即,使用公钥/私钥)连接到数据库。向database
元素添加以下可选属性:
ssl_ca
ssl_cert
ssl_key
例如:
<source>
<database host="localhost" name="magento1" user="root" ssl_ca="/path/to/file" ssl_cert="/path/to/file" ssl_key="/path/to/file"/>
</source>
<destination>
<database host="localhost" name="magento2" user="root" ssl_ca="/path/to/file" ssl_cert="/path/to/file" ssl_key="/path/to/file"/>
</destination>
使用配置和映射文件
数据迁移工具使用映射文件使您能够在 Magento 1 和 Magento 2 数据库之间执行自定义数据库映射,包括:
- 更改表名
- 更改字段名称
- 忽略表或字段
- 将字段的数据传输调整为 Magento 2 格式
支持的 Magento 版本的映射文件位于 <your Magento 2 install dir>/vendor/magento/data-migration-tool/etc
要使用映射文件:
- 将它们从
<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/<migration edition>/<ce or version>/
to复制<your Magento 2 install dir>/app/code/Vendor/Migration/etc/<migration edition>/<ce or version>/
并删除.dist
扩展名。 - 更新
<options>
节点中新复制文件的路径config.xml
。更新后的路径应该是以下之一:- 绝对文件路径,例如
/var/www/html/app/code/Vendor/Migration/etc/opensource-to-opensource/1.9.4.1/map.xml
- magento/data-migration-tool 模块相对文件路径:
etc/opensource-to-opensource/1.9.4.1/map.xml
- Magento 根目录相对文件路径:
app/code/Vendor/Migration/etc/opensource-to-opensource/1.9.4.1/map.xml
- 绝对文件路径,例如
该<Magento 2 dir>/vendor/magento/data-migration-tool/etc
和<Magento 2 dir>/vendor/magento/data-migration-tool/etc/<ce version>
目录包含以下配置文件:
尽管您map.xml.dist
大部分时间都在使用文件,但下表讨论了每个映射和其他文件。
映射文件名 | 描述 |
---|---|
class-map.xml.dist | Magento 1 和 Magento 2 之间的类映射字典 |
config.xml.dist | 指定 Magento 1 和 Magento 2 数据库配置、步骤配置和映射文件链接的主配置文件 |
仅限 Adobe Commerce。customer-attr-document-groups.xml.dist | 自定义客户属性步骤中使用的表列表。 |
仅限 Adobe Commerce。customer-attr-map.xml.dist | 在自定义客户属性步骤中使用的映射文件。 |
deltalog.xml.dist | 包含数据库例程设置所需的表列表。 |
eav-attribute-groups.xml.dist | 包含在 Eav Step 中使用的属性列表。 |
eav-document-groups.xml.dist | 包含在 Eav Step 中使用的表的列表。 |
log-document-groups.xml.dist | 包含在日志步骤中使用的表的列表。 |
map-eav.xml.dist | 在 EAV Step 中使用的映射文件。 |
map-log.xml.dist | 日志映射文件。 |
仅限 Adobe Commerce。map-sales.xml.dist | 在 SalesOrder 步骤中使用的映射文件。 |
map.xml.dist | 映射步骤所需的映射文件。 |
settings.xml.dist | 设置迁移配置文件,指定迁移core_config_data 表所需的规则。 |
customer-attribute-groups.xml.dist | 包含在客户属性步骤中使用的属性列表。 |
customer-document-groups.xml.dist | 包含在客户属性步骤中使用的表的列表。 |
map-customer.xml.dist | 客户属性步骤中使用的映射文件。 |
order-grids-document-groups.xml.dist | 包含在 OrderGrids Step 中使用的表的列表。 |
map-document-groups.xml.dist | 定义在数据插入时发生重复时将更新哪些字段 |
map-stores.xml.dist | 在 Stores Step 中使用的映射文件。 |
map-tier-price.xml.dist | 在层级价格步骤中使用的映射文件。 |
仅限 Adobe Commerce。visual_merchandiser_map.xml.dist | VisualMerchandiser Step 中使用的映射文件。 |
仅限 Adobe Commerce。visual_merchandiser_attribute_groups.xml.dist | 包含 VisualMerchandiser Step 中使用的属性列表。 |
仅限 Adobe Commerce。visual_merchandiser_document_groups.xml.dist | 包含 VisualMerchandiser Step 中使用的表的列表。 |
本文来源于:【Magento中文网】,并添加本文地址链接。
如未按上述操作复制或转载,本站有权追究法律责任。
若本站内容侵犯了原著者的合法权益,可联系我们进行处理。