Saltar al contenido

From Magento 1 to Magento 2: How to successfully migrate your ecommerce

We can divide the migration mainly into 4 steps:

  1. Installation of Magento 2 on our server
  2. Migration of our db source to our db target
  3. Installation and configuration of our theme and extensions
  4. Migration of our media folder to the target environment

Installation of Magento 2 on our server

The first step to proceed with the installation of Magento 2 in our server is the installation of the "Composer" tool, a tool that will be key to us when installing Magento 2 as well as when installing the extensions that we need to use. 

To install Composer we simply need to launch a command, this command varies depending on the operating system we are using.

For UNIX:

De Magento1 a magento2

For Windows:

De Magento1 a Magento2

Once we have installed the tool it is recommended to move it to a global path that facilitates its invocation when necessary, to move it to our new path we can use the following command:

De Magento1 a Magento2

Now that we have installed the tool for the software installation, we can proceed to download Magento 2. In order to do that we simply have to launch the following command:

 “composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition .”

Once the download is completed, we must set the correct permission level in the Magento 2 installation directory. The official Magento documentation recommends using 700 for directories and 600 for files. We can set the two different permission levels using the following command:

De Magento1 a Magento2

The next step would be to create the database that we will use as the destination for the migration. In our case we will use an existing database and a prefix during the installation process.

Now that we have downloaded Magento 2, we can choose two ways to perform the installation. 

The first one is to navigate to the host where we have installed Magento 2 and if everything worked correctly, we should be redirected to the setup tool. 

We can also use another option, which is the one that we will use in our case and that would consist of using the command for setup and installation, along with a series of parameters that should be configured according to our database and other parameters related to the information of our store.

De Magento1 a Magento2

Migration of our db source to our db target

In this step we will see how to migrate all the information from our source bd (catalog, inventory, orders, etc) to our destination bd.

To perform this operation we will have to connect through SSH to our server where we have installed Magento 2 and move to our installation directory.

Once we have moved to the Magento 2 installation directory, we will use the following command to install the data migration tool:

"composer require magento/data-migration-tool: 2.3.5” 

(Sustituye 2.3.5 con la versión de tu Magento 2)

If the installation was successful, the console will display a message like this:

De Magento1 a Magento2

With the data migration tool already installed, we should navigate to the following directory:

vendor/magento/data-migration-tool/etc/opensource-to-opensource/<magento1_version>(In our case: 1.9.3.9). 

Once there, we will duplicate config.xml.dist and rename it to config.xml .

Then, we will edit the file that we have just duplicated (config.xml) and we will configure the access data for our source and destination db.

De Magento1 a Magento2

Further down in the same file, we'll add our cript key  (which we can find in the Magento 1 installation directory → appetc/local.xml) to the tag <cript_key> .

Once we're done, we'll need to navigate to the next folder:

vendor/magento/data-migration-tool/etc/opensource-to-opensource/

There we will duplicate the file settings.xml.dist to settings.xml and copy the latter to the next directory: 

vendor/magento/data-migration-tool/etc/opensource-opensource/<magento1_version>(In our case: 1.9.3.9) 

When we have copied the file, we must edit the file:

vendor/magento/data-migration-tool/etc/opensource-to-opensource/<magento1_version>/config.xml 

And change the value of the label <settings_map_file> with the path of the settings.xml file that we have just copied.

Then, we should go to the next directory:

vendor/magento/data-migration-tool/etc/opensource-to-opensource/<magento1_version>. 

There we will duplicate and rename the file map.xml.dist to map.xml .

With this ready, we will return to edit the file config.xml that we will find inside vendor/magento/data-migration-tool/etc/opensource-to-opensource/<magento1_version> 

and update the value of the label <map_file> with the path to the map.xml file we just created.

With all the configuration part ready, we'll go back to the Magento 2 installation directory and launch the following command:

php bin/magento migrate:data «vendor/magento/data-migration-tool/etc/opensource-to-opensource/<magento1_version>/config.xml» –reset –auto

In our case, the command would be as follows:

php bin/magento migrate:data «vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.9/config.xml» –reset –auto

If everything went well, the console should display a message similar to the following:

De Magento1 a Magento2

 Finally, we should launch a reindex in order to display all the data related to the catalogue on our site.

De magento1 a Magento2

Installation and configuration of our theme and extensions

The installation of our theme/extensions in Magento 2 consists of a series of simple steps.

The first one is to search and buy the theme or extension we want to install in our Magento from the Magento Marketplace itself (https://marketplace.magento.com/). 

Once you have bought your theme/extension you must go to "My Profile" window → Follow the link "My purchases" → Click on the "Technical details" of our extension and copy the values of "Component name" and "Component version".

De Magento1 a Magento2

Then we will start a SSH session in the server where we have installed Magento 2 and we will navigate to the installation directory of the same.

Once there, we will launch the following command:

composer require <component_name>:<component_version> . 

In our case: composer require meetanshi/magento2-cookie-notice:1.0.2 .

Finally we will launch these three commands (The first one to update our setup and the next two to clean the cache):

  • php bin/magento setup:upgrade
  • php bin/magento cache:clean
  • php bin/magento cache:flush

Once all the commands have been executed, we can return to the Magento administration panel and configure the extension at Stores→Settings→Configuration

De Magento1 a Magento2

In the case that what we have installed has been a theme, the process would be practically the same with the peculiarity that we probably need to copy the stylesheets that we had used in our Magento 1 to the Magento 2 directory that is indicated in the extension itself. 

Although in the case of being an Emthemes theme we can edit the styles directly in the section Custom CSS , without having to copy them from one environment to another.

De Magento1 a Magento2
Migration of our media folder to the target environment

The last step, which concludes the Magento migration, is the migration of our media folder to our destination environment.

The media folder is, as its name indicates, where we store all the store's media (product images, banners, logos, etc).

As we can imagine it is a very heavy folder which makes the biggest difficulty of its migration reside in the download/upload times. 

Although the copy process is very simple since it simply consists of copying the media folder from the Magento 1 installation directory to the directory pub/media that we will find inside the Magento 2 installation directory.

Once the copy process is finished, we must launch the following commands:

  • php bin/magento setup:static-content:deploy -f
  • php bin/magento cache:clean
  • php bin/magento cache:flush

This would finish the migration of our website to the latest version of Magento.