参考文档:
https://devdocs.magento.com/guides/v2.2/migration/migration-tool-configure.html
视频地址:
https://www.youtube.com/watch?v=6KPDePFyXZI&list=PL98CDCbI3TNvPczWSOnpaMoyxVISLVzYQ&index=47
数据迁移步骤
1. Install the Magento CE 2.2.7 site
在 数据迁移之前,你必须安装Magento2.2.7 ,且必须是一个空的站点,你不能添加任何的商品,分类,cms block,cms_pages 或者任何更新设置 。
命令:
composer create-project --repository=https://repo.magento.com/ magento/project-community-edition magento_227 2.2.7
安装过程如下:
D:\www>composer create-project --repository=https://repo.magento.com/ magento/project-community-edition magento_227 2.2.7
Installing magento/project-community-edition (2.2.7)
- Installing magento/project-community-edition (2.2.7): Loading from cache
Created project in magento
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 295 installs, 0 updates, 0 removals
- Installing magento/magento-composer-installer (0.1.13): Loading from cache
......
lusitanian/oauth suggests installing predis/predis (Allows using the Redis storage backend.)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
创建数据库: local_migration_lollicupstore
设置url : local.migration.lollicup.com
执行安装命令:
php bin/magento setup:install --base url=http://local.migration.lollicup.com --db-host=localhost --db-name=local_migration_lollicupstore --db-user=root --db-password=root --backend-frontname=admin --admin-firstname=admin --admin-lastname=admin --admin-email=admin@admin.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
上面安装完成之后如下:
安装完成之后依次执行下面的命令:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
2. 安装Data Migration Tool
注意:你当前的Magento的版本必须跟迁移工具的版本一致。
命令如下:
composer require magento/data-migration-tool:2.2.7
下面是安装过程
使用composer加载代码完成之后查看composer.json代码如下:
3. 创建新的数据库导入我们要迁移的数据库
4. 配置迁移工具
1.配置local.xml
找到要迁移的版本:
D:\www\20190813magento2\migration_magento\magento_227\vendor\magento\data-migration-tool\etc\opensource-to-opensource\1.9.3.8
复制config.xml.dist 为 config.xml
打开 config.xml 。
修改下面代码
<source>
<database host="localhost" name="magento1" user="root" />
</source>
<destination>
<database host="localhost" name="magento2" user="root" />
</destination>
修改为
<source>
<database host="localhost" name="local_old2018_lollicupstore" user="root" password="root" />
</source>
<destination>
<database host="localhost" name="local_migration_lollicupstore" user="root" password="root" />
</destination>
如下截图
在local.xml配置文件中找到标记 <crypt_key>,把要导人的站点服务器的
crypt_key 的值,
我的magento 数据库表没有统一的前缀,因此不需要配置这些 <dest_prefix>
2. 配置 map.xml
复制map.xml.dist 为map.xml
5. 执行数据的迁移计划;
php bin/magento migrate:settings vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.8/config.xml
php bin/magento migrate:data -a vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.8/config.xml