Magento2 Migration Guide: migrating from v1.x to 2.x

Magento2 migration guide provides a set of guidelines to migrate your magento online store from v1.x to v2.x. In our last article, we discussed about all aspects of magento2 to help you out in taking the right decision for your online store. If you are convinced that magento2 is the way to go for your online store then this article should help you in migrating your online store. Migrating a functioning store is not the easiest task and you may face various challenges while performing it. You shall loose all your custom changes for the themes or features that you added in your online store.

Though there is already migration guide but that’s very complex and can create confusion.In order to simply the migration process, we describe Magento2 Migration  process in detail, and we really hope it shall help you smoothly migrate and avoid some typical mistakes of Magento2 migration. This article assumes you have basic knowledge of the running command line on linux and can run database queries. If you still are not sure how to do then you can take our professional help for the migration.

If you are looking for ready made magento mobile app then try our 30-day free trial for magento2 and go mobile in few hours.

Prepare to migrate your Magento store

Before doing anything, go and check if the new server suits the Magento System requirements. You need to create a subdomain for the latest magento2 and point it to the new directory. It is possible you may need to set up your PHP or install the extensions missing. Also, make sure you have enough disk space on the new server; it should be okay to store the whole shop plus you need some spare space.  Most important task would be take backup of the existing online magento store using one of the backup magento extensions.

In this article, we are demonstrating the migration from Community Magento 1.9.0.1 to latest Magento 2.x on Centos OS system, If you are using Ubuntu then prefix Sudo in your command line, Ideally this guild should work on the other versions too but let us know if you face any other issues for your migration.

Step by Step Magento2 Migration Guide

1. Magento2 installation

First of all you need to put your existing online store in the maintenance mode. You can use this plugin to put the site on maintenance mode. We shall use the composer utility to download the magento2 as it’s relatively less error prone and faster way. You can look at more details for the composer installation.

  1. SSH to your server and change directory to the webroot directory.
  2. Enter following command to download the latest magento2 on your server:
    composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <Directory-Name>
  3. Installation shall ask your username(public key) and password(private key) which you can get from secure keys under your magento account.
  4. Once the magento2 is downloaded on your server, next step shall be to create the new database from mysql client and set permissions to the directories:
    Create Database Magento2;
    find . -type d -exec chmod 770 {} ; && find . -type f -exec chmod 660 {} ; && chmod u+x bin/magento
  5. Now we need to install the magento2 on the existing server using website wizard i.e. http://magento22.pragmaapps.com/setup/. After completion of the installation, you can check the new store frontend and backend to make sure installation was successful.
  6. We need to enable to cronjob for the magento2 so that we can have magento2 is able to do the background tasks smoothly(caching, indexing etc.)
Magento2 Admin Panel
Magento2 Admin Panel

2. Magento2 Migration

This is the critical & difficult part of the migration and one need to be extra caucious about it.  Magento2 migration tool only migrate the default magento data and your custom changes shall not be migrated to the latest version.

  1. Download and Install the migration tool using following. For example, for version 2.0.2, enter:
    composer config repositories.magento composer https://repo.magento.com
    composer require magento/data-migration-tool:2.0.2
  2. Copy the existing config.xml.dist to config.xml. Configure the migrations settings in the config.xml file in your migration directory (we are using 1.9.0.1 community version) <Magento2 Directory>/vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.0.1/.
    <source>
        <database host="127.0.0.1" name="magento1" user="root" password="pass"/>
    </source>
    <destination>
        <database host="127.0.0.1" name="magento2" user="root" password="pass"/>
    </destination>
    <options>
        <source_prefix/>
        <crypt_key>f3e25abe619dae2387df9fs594f01985</crypt_key>
    </options>
    

    The <crypt_key> tag is mandatory to fill. It can be found in local.xml file which is located in the directory of Magento 1 instance at app/etc/local.xml in <key> tag

  3. Configure the mapping <Magento2 Directory>/vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.0.1/map.xml.dist for the entries which needs to be ignored e.g. in our case we need to ignore third party structures:
    <ignore>
          <document>aw_blog</document>
       </ignore>
       <ignore>
          <document>aw_blog_cat</document>
       </ignore>
       <ignore>
          <document>aw_blog_cat_store</document>
       </ignore>
       <ignore>
          <document>aw_blog_comment</document>
       </ignore>
       <ignore>
          <document>aw_blog_post_cat</document>
       </ignore>
       <ignore>
          <document>aw_blog_store</document>
       </ignore>
       <ignore>
          <document>aw_blog_tags</document>
       </ignore>
       <ignore>
          <document>sm_menu_groups</document>
       </ignore>
       <ignore>
          <document>sm_menu_items</document>
       </ignore>
  4. And ignore some of the columns in the tables:
    <ignore>
          <field>sales_flat_invoice.customer_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_invoice.invoice_status_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_invoice.invoice_type</field>
       </ignore>
       <ignore>
          <field>sales_flat_invoice.is_virtual</field>
       </ignore>
       <ignore>
          <field>sales_flat_invoice.real_order_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_invoice.total_due</field>
       </ignore>
       <ignore>
          <field>sales_flat_invoice.total_paid</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.base_custbalance_amount</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.currency_base_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.currency_code</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.currency_rate</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.custbalance_amount</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.is_hold</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.is_multi_payment</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.real_order_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.tax_percent</field>
       </ignore>
       <ignore>
          <field>sales_flat_order.tracking_numbers</field>
       </ignore>
       <ignore>
          <field>sales_flat_order_payment.amount</field>
       </ignore>
       <ignore>
          <field>sales_flat_order_payment.cc_raw_request</field>
       </ignore>
       <ignore>
          <field>sales_flat_order_payment.cc_raw_response</field>
       </ignore>
       <ignore>
          <field>sales_flat_order_payment.customer_payment_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_order_address.address_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_order_address.gift_message_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_order_address.tax_id</field>
       </ignore>
       <ignore>
          <field>sales_flat_invoice_item.shipment_id</field>
       </ignore>
  5. Now we are ready for migration and run the following command to migrate the settings:
    bin/magento migrate:settings <Magento2 Directory>/vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.0.1/config.xml
  6. Migrate the data using following:
    bin/magento migrate:data  <Magento2 Directory>/vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.0.1/config.xml
  7. Migrate the delta data using following(Press Ctlr+C to abort):
    bin/magento migrate:delta -r <Magento2 Directory>/vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.0.1/config.xml
  8. Manual Data Migration : All media files (for example, images for products, categories, the WYSIWYG editor, and so on) should be copied manually from <your Magento 1 install dir>/media to <your Magento 2 install dir>/pub/media. However, do not copy .htaccess files located in the Magento 1 media folder. Magento 2 has its own .htaccessthat should be preserved.

3. Switch the domain for Magento2

Once the migration is done and you tested everything to be working, it is time to live the latest online store. You can configure the virtual host and point the magento2 as main server.

Known Magento2 Migration issues:

Issue 1: Unable to view Admin Catalog

After the migration, You can get the following exception when  you try to view the catalogs in your store:

SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '', query was: SELECT COUNT(DISTINCT main_table.attribute_id) FROM `eav_attribute` AS `main_table` INNER JOIN `eav_entity_type` AS `entity_type` ON main_table.entity_type_id = entity_type.entity_type_id INNER JOIN `eav_entity_attribute` ON main_table.attribute_id = eav_entity_attribute.attribute_id INNER JOIN `` AS `additional_table` ON main_table.attribute_id = additional_table.attribute_id WHERE (`entity_type_code` = 'catalog_product') AND (`additional_table`.`is_used_in_grid` = 1)

Solution: The issue is due to column ‘additional_attribute_table’ is not set by migration tool and can be fixed by running following queries:

update eav_entity_type set additional_attribute_table='catalog_eav_attribute'  where entity_type_code='catalog_product';

After running the query, run the following command:

php bin/magento indexer:reindex && php bin/magento cache:clean

Issue 2: Unable to Add/Edit Catalog product from Admin

The Catalog screen doesn’t load when you try to edit or add the project. If you looked at the log then you get following exception:

Class media_image does not exist

Solution: The issue is due to custom attribute is not set by migration tool and can be fixed by running finding the attribute id of the image and run the following queries(in our case Attribute Ids were 106,109):

update catalog_eav_attribute set catalog_eav_attribute.frontend_input_renderer='MagentoCatalogBlockAdminhtmlProductHelperFormBaseImage' where  catalog_eav_attribute.attribute_id in (106,109)

After running the query, run the following command:

php bin/magento indexer:reindex && php bin/magento cache:clean

Like this magento2 migration guide?  Take a second and use the share buttons on the left-side to share it with your online store merchants – they’ll appreciate you for it!

Feel free to contact us for a free consultation on your online store magento2 migration. Let us know your availability for a quick call and we shall explore how we can help with your online store.

Leave a Comment

Scroll to Top