We can divide the migration mainly into 4 steps:
- Installation of Magento 2 on our server
- Migration of our db source to our db target
- Installation and configuration of our theme and extensions
- 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.
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:
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:
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.
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:
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: 188.8.131.52).
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.
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:
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: 184.108.40.206)
When we have copied the file, we must edit the file:
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:
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/220.127.116.11/config.xml» –reset –auto
If everything went well, the console should display a message similar to the following:
Finally, we should launch a reindex in order to display all the data related to the catalogue on our site.
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".
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
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.
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.
We are passionate about writing content on e-commerce and technology, in order to help our clients improve their business and increase sales. Subscribe to our monthly newsletter and don't miss out on the valuable insights and resources we have to share.