Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Magento 2 Development Cookbook

You're reading from   Magento 2 Development Cookbook Over 60 recipes that will tailor and customize your experience with Magento 2

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781785882197
Length 304 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Toc

Table of Contents (13) Chapters Close

Preface 1. Upgrading from Magento 1 FREE CHAPTER 2. Working with Products 3. Theming 4. Creating a Module 5. Databases and Modules 6. Magento Backend 7. Event Handlers and Cronjobs 8. Creating a Shipping Module 9. Creating a Product Slider Widget 10. Performance Optimization 11. Debugging and Unit Testing Index

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.

You have been reading a chapter from
Magento 2 Development Cookbook
Published in: Dec 2015
Publisher:
ISBN-13: 9781785882197
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image