Migrate easily Magento 1 to Magento 2 Using command line


First you normally backup the magento 1 data base and import the your new sever .

Let's start,

For magento 2 data migration you need a fresh setup for magento 2. And download you want to magento version https://devdocs.magento.com/guides/v2.4/install-gde/bk-install-guide.html

Step 1 :  As we will do it with composer , so check composer is installed or not with
=> composer –V

If you get output like

Composer version 1.0-dev (e8b1a5f35772e39ca21ab855a278bd84a0a534b2) 2016-03-29 07:53:57

Then it means composer is installed on the system , if not then you can install composer by

#cd /tmp
Download the composer.phar file

#curl -sS https://getcomposer.org/installer | php
Move it to /usr/local/bin/

#mv composer.phar /usr/local/bin/composer
Now you can to use the command composer globally.

Now Install data migration tool with composer for magento 2.0.2 , which is the version use by me

#composer config repositories.data-migration-tool git https://github.com/magento/data-migration-tool

#composer require magento/data-migration-tool:2.0.2

It will prompt for user name and password , then you need to have an magento account from which 
you can create secure keys which will work as.

User name – public key
Password – private key

After the enter user name and password it will install the data migration tool inside the vender/magento/ directory

You can take Overview for magento 2 data migration tool inside the vendor/magento/data-migration-tool/

Suppose there is need to do community to community edition migration , the we need to go inside the ce-to-ce  , inside this folder there are multiple versions for magento  as 


You can see different of versions here for magento 1.X here , also there are files with xml.dist extension , you need to replace all file extension with .xml

Now go inside the version directory from which you want to migrate ,for me its 1.9.2.1

So enter the directory and you will see two files here
config.xml.dist  
map.xml.dist

Replace these files with xml extention
Like :- 
config.xml  
map.xml 

After renaming the files open config.xml and change the source and destination database configuration

One more important thing if you are doing server to server data migration then replace the source host name with the ip or hostname or source server host.

For remote host access you should have remote host access for database on source server  , which can be easily given by phpmyadmin or mysql command line.

Here is the example for configuration

<source>
    <database host="192.168.1.29" name="sourcedb" user="sourceuser" password="password" />
</source>
<destination>
    <database host="localhost" name="destinationdb" user="destingationuser" password="password"/>
</destination>

There are some other change require in the config.xml , you need to replace crypt key , in the 
config.xml
You can find this key from mageto 1.9.x’s local.xml file

Copy the key and insert in the config.xml file

There is also need to rename files added with xml.dist extension to xml  in the config.xml file.

Once it is done we can start migration

Step 1 : Migrate settings: first migrate settings , it will assure that all config.xml values are fine
Go to magento 2 project document root and run the following command

php bin/magento migrate:settings vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.2.1/config.xml

Step 2 :
Migrate Data: Now need to migrate all the data from magento 1.9.X to 2.x  , run the command

php bin/magento migrate:data vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.2.1/config.xml

In this step we can get errors
I think you found the ignore error
We need to ignore these values in the map.xml  file in document rule tag , as per requirement for example:-

<ignore>
       < document>pricespider</document>
</ignore>

Where pricespider is ignore value, after the changes in map.xml  save it and again execute the data migration command
Hope you complete the data migration .
You can see data migration log in var/migration.log as well

Step 3: There are some changes need to do manually, for this you need to follow the steps
There are three types of data that need to be manually migrated:
Media
Storefront design
Admin users
ACLs

Media
This section discusses how to manually migrate media files.

Media files stored in the database

This section applies to you only if you store media files in the Magento database. This step should be 
performed before migration of data

Log in to the Magento 1 Admin Panel as an administrator.
Click System > Configuration > ADVANCED > System.
In the right pane, scroll to Storage Configuration for Media.
From the Select Media Database list, click the name of your media storage database.
Click Synchronize.

After that, use the following steps:
Log in to the Magento 2 Admin as an administrator.
Click Stores > Configuration > ADVANCED > System.
In the right pane, scroll to Storage Configuration for Media.
From the Select Media Database list, click the name of your media storage database.
Click Synchronize.

Media files on the file system

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 .htaccess that should be preserved.

Storefront design
Design in files (css, js, templates, XML layouts) changed its location and format
Layout Updates stored in database. Placed through Magento 1 Admin in CMS Pages, CMS Widgets, Category Pages and Product Pages

ACLs (Access Control Lists)
You must manually re-create all credentials for web services APIs (that is, SOAP, XML-RPC, and REST)
You must manually re-create all administrative users and associate them with access privileges

And Finally run this command :-
Do reindexing of all data
#php bin/magento indexer:reindex

Setup upgrade
#php bin/magento setup:upgrade

Flush cache
Php bin/magento indexer cache:flush

Give proper permission
#Chmod –R 777 var/ pub/static pub/media 

Comments

  1. Flush Command is mistyped.

    `Php bin/magento indexer cache:flush`
    remove `inderxer`
    it is `php bin/magento cache:flush`

    ReplyDelete

Post a Comment