-
Book Overview & Buying
-
Table Of Contents
Magento 2 Development Cookbook
By :
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.
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:
composer config repositories.data-migration-tool git https://github.com/magento/data-migration-tool-ce composer require magento/data-migration-tool:2.0.0
php bin/magento migrate:data --help
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
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>
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
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.
Change the font size
Change margin width
Change background colour