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

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.

主站蜘蛛池模板: 自贡市| 喀什市| 仪征市| 临高县| 邹城市| 阳山县| 宝丰县| 芷江| 体育| 金寨县| 十堰市| 恩平市| 虎林市| 婺源县| 资兴市| 石柱| 永安市| 吉首市| 双桥区| 平舆县| 揭阳市| 玉林市| 靖边县| 古交市| 临汾市| 塘沽区| 墨玉县| 台南市| 平果县| 和平县| 牡丹江市| 朝阳区| 清新县| 应用必备| 永寿县| 天台县| 囊谦县| 开阳县| 开原市| 普兰县| 通城县|