官术网_书友最值得收藏!

Preparing an upgrade from Magento 1

The differences between Magento 1 and Magento 2 are huge. The code has a whole new structure with a lot of improvements but there is one big disadvantage. What do I do if I want to upgrade my Magento 1 shop to a Magento 2 shop?

Magento created an upgrade tool that migrates the data from a Magento 1 database to the right structure for a Magento 2 database.

The custom modules in your Magento 1 shop will not work in Magento 2. It is possible that some of your modules will have a Magento 2 version, and depending on the module, the module author will have a migration tool to migrate the data that is in the module.

Getting ready

Before we get started, make sure you have an empty (without sample data) Magento 2 installation with the same version as the Migration tool that is available at:

https://github.com/magento/data-migration-tool-ce.

How to do it...

  1. In your Magento 2 version (with the same version as the migration tool), run the following commands:
    composer config repositories.data-migration-tool git https://github.com/magento/data-migration-tool-ce
    composer require magento/data-migration-tool:2.0.0
    
  2. Install Magento 2 with an empty database by running the installer. Make sure you configure it with the right time zone and currencies.
  3. When these steps are done, you can test the tool by running the following command:
    php bin/magento migrate:data --help
    
  4. The next thing is creating the configuration files. Examples of the configuration files are in vendor/magento/data-migration-tool/etc/<version>. We can create a copy of this folder where we can set our custom configuration values. For a Magento 1.9 installation, we have to run the following cp command:
    cp –R vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.1.0/ vendor/magento/data-migration-tool/etc/ce-to-ce/packt-migration
    
  5. Open the vendor/magento/data-migration-tool/etc/ce-to-ce/packt-migration/config.xml.dist file and search for the source/database and destination/database tags. Change the values of these database settings to your database settings like in the following code:
    <source>
      <database host="localhost" name="magento1" user="root"/>
    </source>
    <destination>
      <database host="localhost" name="magento2_migration" user="root"/>
    </destination>
  6. Rename that file to config.xml with the following command:
    mv vendor/magento/data-migration-tool/etc/ce-to-ce/packt-migration/config.xml.dist vendor/magento/data-migration-tool/etc/ce-to-ce/packt-migration/config.xml
    

How it works...

By adding a composer dependency, we installed the data migration tool for Magento 2 in the codebase. This migration tool is a Magento console command that will handle the migration steps from a Magento 1 shop.

In the etc folder of the migration module, there is a sample configuration of an empty Magento 1.9 shop.

If you want to migrate an existing Magento 1 shop, you have to customize these configuration files so it matches your preferred state.

In the next recipe, we will learn how we can use the script to start the migration.

主站蜘蛛池模板: 图木舒克市| 邳州市| 赣榆县| 曲靖市| 晋中市| 赞皇县| 河西区| 黄龙县| 阿坝县| 岳阳市| 闽清县| 建平县| 墨脱县| 诸暨市| 重庆市| 惠安县| 贵德县| 安泽县| 微山县| 通化市| 惠来县| 新密市| 临夏县| 乐亭县| 兴隆县| 德化县| 五大连池市| 仲巴县| 霍州市| 铁力市| 光山县| 基隆市| 西贡区| 宜兰县| 仁寿县| 织金县| 尼勒克县| 罗源县| 东港市| 延吉市| 福州市|