Data Migration Tool : Migrating Magento 1 to Magento 2

Data Migration Tool : Migrating Magento 1 to Magento 2

To ease up migration process, Magento released official Data Migration Tool that will help developers migrate data from Magento 1 to Magento 2. The Data Migration Tool is a command-line interface (CLI) that provides verification, progress tracking, logging, and testing functions. It is intended to protect data integrity and reduce downtime during migration.

Let’s have a look at the migration process using Data Migration Tool.

Prerequisites

Before you start your migration, you must do all of the following steps:

  • Set up a Magento 2.0 system that at least matches your existing Magento 1 system.
  • Do not start Magento 2 cron jobs.
  • After installation back up or dump your Magento 2 database as soon as possible.
  • Check that the Data Migration tool has a network access to connect the Magento 1 and Magento 2 databases.
  • Replicate your Magento 1.x database and use this data for your migration.
  • Migrate Magento 1 extensions and custom code to Magento 2.
  • Make sure you are using the same released version of both Magento 2 and the Data Migration Tool. To find the version of either package, open composer.json and find the value of “version“.

Install & Upgrade the Data Migration Tool

You can install the Data Migration Tool from either repo.magento.com or from a GitHub repository. For the installation process, use the following steps:

  1. Log in to your Magento 2 server as a user with root privileges or switch to the web server user.
  2. Change to Magento 2 root directory.
  3. Use the following commands:
    Enter the commands in the order to Install the tool from repo.magento.com:

    composer config repositories.magento composer https://repo.magento.com
    composer require magento/data-migration-tool:<version>
    

    To install the migration tool from GitHub:

    composer config repositories.data-migration-tool git https://github.com/magento/data-migration-tool
    composer require magento/data-migration-tool:<version>
    
  4. Wait while dependencies are updated/installed.

The versions of the Data Migration Tool and your Magento software must exactly match.

To find the version of the Magento software:

  • If you downloaded the Magento software using a Composer metapackage, use the following command to find the version of Magento:
    php <your Magento install dir>/bin/magento --version
    
  • If you cloned the Magento 2 GitHub repository, enter the commands:
    cd <your Magento 2 clone directory>
    git branch
    

To find the version of Data Migration Tool, open composer.json and find the value of “version“.

Before you upgrade the Data Migration Tool, you must upgrade your Magento software and back up the vendor/magento/data-migration-tool directory. The vendor/magento/data-migration-tool directory contains your custom code. It could be modified and can lose your code during the upgrade process.

Use the following steps to upgrade the Data Migration Tool:

  1. Log in to your Magento server as the Magento file system owner.
  2. Change to Magento 2 root directory.
  3. Enter the following command:
    composer require magento/data-migration-tool:<version>
    

    where <version> is the version of the Magento 2 codebase.

  4. Wait while the above command completes successfully.

We have successfully installed/upgraded the Data Migration Tool.

Configure migration

After you install the data migration tool, the <your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/ directory contains mapping and configuration files. Before you migrate any data, you must create a config.xml configuration file from the provided sample.

To create a config.xml, use the following steps:

  • Change to <your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/<migration edition>/<ce or version> directory.
  • Enter the command: cp config.xml.dist config.xml
  • Add the following details at minimum:
    <source>
     <database host="127.0.0.1" name="magento1" user="root"/>
    </source>
    <destination>
     <database host="127.0.0.1" name="magento2" user="root"/>
    </destination>
    <options>
     <map_file>map-file.xml</map_file>
     <crypt_key />
     .............
    </options>
    

    <source>  – configuration for data source (database).
    <destination> – configuration for data destination (database).
    <options> – list of parameters. Contains both mandatory (map_file, settings_map_file, bulk_size) and optional (custom_option, resource_adapter_class_name, prefix_source, prefix_dest, log_file) parameters.
    The <crypt_key> tag 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.

  • When you’re finished, save your changes to config.xml.

The Data Migration Tool uses mapping files to enable you to perform custom database mapping between your Magento 1 and Magento 2 databases. In case Magento 1 contains tables or fields that belong to some extension that does not exist in Magento 2, then these entities can be placed in map.xml to ignore them by Map Step. Otherwise it will show an error message.

For more details on configuration and mapping please refer to Data Migration Tool Internal Specification.

Migrate using the data migration tool

The migration tool operates in three modes to transfer and adapt data from Magento 1 to Magento 2:

  • Settings mode: You should migrate settings first. This mode migrates stores; websites; and all possible configuration settings like shipping, payment, some tax settings etc.
  • Data mode: Migrates database assets in bulk from Magento 1 to Magento 2 database.
  • Delta mode: Incremental migration enables you to migrate only the changes made in Magento 1 since the last time you migrated data.

To run the migration tool to migrate settings, data, or incremental changes, use the following steps.

  1. Log in to your Magento server as the Magento file system owner. If you use the bash shell, you can also use the su <Magento file system owner> -s /bin/bash -c <command> syntax to switch to the Magento file system owner.
  2. Add <your Magento install dir>/bin to your system PATH, to run Magento commands from any directory.
  3. Enter the command:
    bin/magento migrate:<mode> [-r|--reset] {<path to config.xml>}
    

    where
    <mode> is settings, data, or delta.
    {<path to config.xml>} is the absolute file system path to config.xml; this argument is required.
    [-r|–reset] is an optional argument that starts migration from the beginning. You can use this argument for testing migration.

For example:
To migrate data, use the following command:
bin/magento migrate:data [-r|–reset] {<path to config.xml>}

Logs are written to the <your Magento install dir>/var/ directory. The Data Migration Tool has special handler \Migration\Handler\Timezone for transforming time to a different time zone. Using it you can change time for some fields of database that can be specified in your map.xml file with offset parameter. It also takes care of some behavioural and logical changes in magento 2 from magento 1.

See the official Documentation for more details on Data Migration Tool. Hope this will help you !! 🙂 🙂

 

Migrate from Magento 1.x to Magento 2.0

Migrate from Magento 1 to Magento 2

Magento 2 has definitely brought in some features which improves the interface and overall experience for Magento developers and users. Have you ever considered moving from Magento 1 to Magento 2 ? Here is an overview of this process, which is referred to as migration. Just like an upgrade between different versions of Magento 1.X , the level of effort to migrate from Magento 1 to Magento 2 depends upon how you have built your site and its level of customization.

Migration from Magento 1.x to Magento 2 involves four components: data, extensions, themes, and customizations.

  • Data: There are many differences in the structure and format of data that is stored in database between Magento 1 and Magento 2. Each version of Magento has its own unique changes in data structure. To ease up the  Migration process, Magento released an official Data Migration Tool that will help developers to transfer store data from older versions of Magento to the latest Magento 2. The Data Migration Tool transfers all of your key product, customer, and order data, store configurations, promotions and more to Magento 2.
  • Extensions and custom code: If you want to migrate some of your extensions , you might need to install these extensions adapted for Magento 2. Reach out to your extension providers to see if they have been ported yet. Custom code is not ported because it cannot be automated.
  • Themes and Customizations: Themes and customizations of your magento 1 store cannot be automatically migrated to Magento 2. Developers will need to make changes to their themes and customizations for Magento 2.

Data Migration Tool

The Data Migration Tool is a command-line interface (CLI) that provides verification, progress tracking, logging, and testing functions. Data Migration Tool transfers data from Magento 1 to Magento 2 database and it is intended to protect data integrity and reduce downtime during migration. You can install it from either repo.magento.com or from a GitHub repository.
The migration tool operates in three modes to transfer and adapt data from Magento 1 to Magento 2:

  1. Settings mode: You should migrate settings first. This mode migrates stores; websites; and all possible configuration settings like shipping, payment, some tax settings etc.
  2. Data mode: Migrates database assets in bulk from Magento 1 to Magento 2 database.
  3. Delta mode: Incremental migration enables you to migrate only the changes made in Magento 1 since the last time you migrated data.

Each mode consists of several steps that perform tasks specific to the mode. Each step initially checks data integrity in the Magento 1 and Magento 2 databases and, after verification succeeds, it performs the transfer of data.

There are some types of data like media, storefront design, admin users and ACLs (Access Control Lists) that need to be manually migrated. Media files can simply be copy/pasted to appropriate locations in Magento 2. You must manually re-create all credentials for web services APIs , all administrative users and associate them with access privileges.

The Migration Process

To have a successful migration from Magento 1 to Magento 2 , refer to the following steps:

  • Set up a Magento 2.0 system using a topology and design that at least matches your existing Magento 1 system.
  • Replicate your Magento 1.x database and use this data for your migration.
  • Install Magento 2.
  • Check that the Data Migration tool has a network access to connect the Magento 1 and Magento 2 databases. Open ports in your firewall so the migration tool can communicate with the databases.
  • Stop all activity in the Magento 1.x Admin Panel. Activity cannot resume until your Magento 2 store goes live.
  • Stop all Magento 1.x cron jobs.
  • Use the migration tool to migrate settings and websites.
  • Copy your Magento 1.x media files to Magento 2.0.
  • Use Data Migration Tool to migrate your data from Magento 1 database to Magento 2 database.
  • Use the magento indexer:reindex command to reindex all indexers.
  • Thoroughly test your Magento 2.0 site.
  • Start the incremental migration. Incremental migration enables you to migrate only the changes made in Magento 1 since the last time you migrated data. Test your Magento 2 site during this time so you can catch any issues as soon as possible.

Now your Magento 2 site is up-to-date with Magento 1.

  • Put Magento 1 in maintenance mode and permanently stop all Admin activities.
  • Start Magento 2 cron jobs.
  • Flush all Magento 2 cache types and reindex all Magento 2 indexers.
  • Perform any final verification of your Magento 2 site.
  • Change DNS, load balancers, and so on to point to new production hardware.

And that’s it !!! Your Magento 2 store is ready to use. You and can resume all activities.

For full information please see the official Migration Guide. Share your experience in comments, and we’ll be happy to help you. 🙂 😀

 

How to create a configurable product in Magento?

How to create a configurable product in Magento?

A Configurable product in Magento is a combination of simple products.For example, a mobile phone cover comes in three colors for two versions. Here we will have a single Configurable product with two options: version and color; that ties six simple products.Each variation has its own SKU and inventory listing.You would create six Simple Products individually and then group these six as a Configurable Product; allowing customers to select which version and color they wish to buy.

The following instructions take you through the process of creating a configurable product in Magento.

The basic steps to create a configurable product in Magento are:

  • Create attributes.
  • Create the attribute set.
  • Create a new configurable product.
  • Adding Associated Products to a Configurable Product.

Create attributes.

Create an attribute for each option that you want to include in the configurable product.If the attribute already exists, you can assign it to a particular attribute set in the next step.To create an attribute,Go to “Catalog> Attributes> Manage Attributes”. Then select “Add New Attribute” in the top right corner.Enter an Attribute Code for your attribute and the Scope should be set to Global.The Catalog Input Type for Store Owner is set to Dropdown. Apply To should be Selected Product Types, and in the box below select Simple Product and Configurable Product to make the attribute apply to these two types. Set the Use to Create Configurable Product drop-down menu to Yes in order to use the attribute for creating configurable products.

attribute

attribute

The attribute option values and their sort order have been entered in the Manage Label/Options section.
Make sure to click “Save Attribute” when you’re done the above steps.

Create the attribute set.

Before you add a configurable product you have to make sure that the necessary attribute(s) is added to your Magento. Go to “Catalog >> Attributes >> Manage Attribute Sets” and press “Add New Set”. Give the attribute set name and leave it based on default. Continue to the next page.

configurable_attribute_set

Here you’ll see two panels where the left panel shows attributes that are part of the set and the right panel has unassigned attributes.Drag  the required attributes into the left panel, and then click “Save Attribute Set” button in the top right.You can then select that set when adding the new configurable product.

Create a new configurable product.

Navigate to “Catalog >> Manage Products”. Press “Add Product” button.Create a Configurable Product based on the required attribute set.In the next screen you need to pick which attributes you want to associate.Select all required attributes for your Configurable product and then press “Continue” button.Complete the Product Information as you would do for a Simple product.

configurable_product

configurable_product

configurable_attribute

configurable_attribute

Adding Associated Products to a Configurable Product.

After you set up all the basic settings of the configurable product, it’s time to create the associated products.In the panel on the left, select the tab option “Associated Products”.There are three different ways to add the associated products: Create Empty, Copy from Configurable and Quick Create.

The “Create Empty” option will give a new product configuration page with all the options and fields empty. This is exactly the same as creating a simple product.
The “Copy From Configurable” option will also display the same product configuration page but most of the fields will be filled with the values that you entered for the configurable product.
In “Quick Create”, there are several options that you have to configure. This is the fastest way to add the associated products. Fill all fields and then click “Quick Create” button to create the associated product record.Repeat this step for each associated product for your configurable product.

configurable product in magento

Associated_Products_Magento

Use the Super Products Attributes Configuration section just under the Quick Create section to make price adjustments to a specific associated product.

 

You’re all done.Click Save button in the top menu to save your Configurable product. 🙂

Redirect logged in customer to account page when accessing a cms page

1. Call a custom template from your cms/page.

{{block type="core/template" name="visitor_page" template="YourTemplateFolder/TemplateFileName.phtml"}}

2. Then in your .phtml add the following code. For example

$logged_in = Mage::getSingleton('customer/session' )->isLoggedIn();
if ($logged_in){
$url = Mage::getUrl('customer/account');
Mage::app()->getResponse()->setRedirect($url);
return;
}