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. 🙂 😀

 

Bundle Products in Magento 2.0

Bundle Products in Magento 2.0

A bundle product in magento allows customers to build their own customized version of a product from a miscellaneous collection of options. You can sell simple ,configurable and virtual products as parts of a bundle product.For example , if someone is buying a Customizable Computer System then user must have some options to select RAM and Hard Disc size,cabinet,CPU etc. Once the product is configured, user will place an order for a fully build Computer System. The final price of the product will depend on what the customer selects as options.

How do you proceed if you need to add a new bundle product in Magento 2.0?  This tutorial will show you how to create a bundle product in your Magento store.

Bundle Product

Let’s take the above example of selling desktop PCs. We can see that this product has options. Each custom option’s value corresponds to one simple product. So before creating a bundle product you need to create several simple products that are associated with the bundle product. Click here  to know how to add a simple product in Magento 2.0

  • Step 1 :

To add a new bundle product, Navigate to the Products>Catalog section from the Magento admin panel. Click the “Add Product” button to start configuring a new Product. You can choose the “Bundle Product” option from the drop-down box available here.

Add Bundle Product

  • Step 2 :

Fill up the product details of the main product. Here you can choose SKU, Weight and price either to be dynamic or fixed. Dynamic value option means that your bundle product value will depend on the value of each product in the Bundle. The fixed values will not change on customer’s choice. You can also select the shipment mode (together or separately) for the product items. Now click on “Create New Option” button at the bottom of the page.

Bundle product details

  • Step 3 :

Now we need to add customizable options for our bundle product. I have added CPU in the first option and set it as a default choice.

Bundle product options

To add products to the option, press “Add Products to Option” button. Choose products you want to add to the option. Press “Add selected Products” button to add the products to option.

Bundle option products

  • Step 4 :

Create as many option as you want to include in your bundle product. I have added options CPU , cabinet , RAM , Hard Disk Drive and monitor for my product “Desktop PC”.

Bundle product save

When this is done , click on “save” button to save all product information you have created. Now you can configure your product settings for Images and Videos, SEO description, websites etc. 🙂

 

Creating a Simple Module in Magento 2.0

Magento 2.0 – Create A Simple Module

Modules are an integral part of Magento. The purpose of each module is to provide specific product features by implementing new functionality or extending the functionality of other modules. Developing a custom module gives us the freedom to implement customized solutions for a particular business need. Let’s have a look at creating a simple module in Magento 2.0.

Creation of a module in Magento 2.0 is quite different from Magento 1.X. In magento 2.0, all the modules are grouped by vendor. Hence, We can create modules right inside the app/code directory.

Every module in Magento 2.0 has unique name that’s made up of two parts. For example, we’re going to create a module named Zgento_LightBox. The first part (Zgento) is called the VendorName describes the company or individual that built the extension. The second part, LightBox, describes what the extension does(Lightbox gallery with next and previous buttons to easily navigate through product images).

  • Step 1: Create the Directories.

To start with our module we’ll create the directory: app/code/Zgento/LightBox. The code pools(local, community, and core) are eliminated in Magento 2.0. We can now directly create the modules inside the app/code directory.

We’ll also create the following sub-directories:

  • app/code/Zgento/LightBox/
  • app/code/Zgento/LightBox/Block/
  • app/code/Zgento/LightBox/Controller/Index/
  • app/code/Zgento/LightBox/etc/
  • app/code/Zgento/LightBox/view/frontend/layout
  • app/code/Zgento/LightBox/view/frontend/templates

The “view” folder is entirely new. Layout and template files are saved in the folder “View” in the module.

  • Step 2: Declare the Module.

We’ll start with our configuration files. Write the file module.xml in app/code/Zgento/LightBox/etc/module.xml to declare the module. This module.xml file is the main module configuration file. The module.xml file is for registering the module.

<!-- File: app/code/Zgento/LightBox/etc/module.xml -->
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Zgento_LightBox" schema_version="1.0.0" setup_version="1.0.0" />
</config>

The <module/> node tells Magento we want to add a module to the system. The name attribute indicate the name of the module, and the setup_version attribute tells the version of our module.

  • Step 3: Adding a Controller Action.

Now we can create our Controller action. Create the file Index.php in app/code/Zgento/LightBox/Controller/Index/Index.php
Here the folder Index is name of the controller and index.php is an action file.

# File: app/code/Zgento/LightBox/Controller/Index/Index.php
<?php namespace Zgento\LightBox\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { public function execute() { $this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
}

The base class Magento\Framework\App\Action\Action is the standard base class for frontend controllers. The method excute() will be involked when the action is called.

  • Step 4: Creating a Block Class.

Let’s create a block for our module. Create block file app/code/Zgento/LightBox/Block/LightBox.php

<?php
namespace Zgento\LightBox\Block;
class LightBox extends \Magento\Framework\View\Element\Template
{

}

In the above example we have not implemented any methods,but if we were to implement some methods, in our template we would have access to them via the $block variable. Magento\Framework\View\Element\Template is Magento’s base template class.

  • Step 5: Layout files & Templates.

Now we need to create our layout configuration file and the template.

Let’s create a layout with the following name:
/Zgento/LightBox/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

<update handle="Zgento_lightbox"/>
<head>
<css src="Zgento_LightBox::css/lightbox.css"/>
<script src="Zgento_LightBox::js/lightbox.js"/>
</head>

<body>
<referenceBlock name="product.info.media.image" >
<action method="setTemplate" ifconfig="zgento_lightbox/general/enable">
<argument name="template" xsi:type="string">Zgento_LightBox::product/view/gallery.phtml</argument>
</action>
</referenceBlock>

</body>
</page>

In <head> tag, we can add files to the page such as adding CSS, js etc. In above example, we added the styles & js files to use when showing on frontend.

Now we need to create our template file gallery.phtml in the following directory.
app/code/Zgento/LightBox/view/frontend/templates/product/view/gallery.phtml

Once we have completed all the above steps, we need to activate our extension manually.

  • Step 6: Activate our Extension.

Let’s create registration.php file in the root folder of the module and put the following code inside:

# File: app/code/Zgento/LightBox/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Zgento_LightBox',
__DIR__
);

This is done to tell Magento 2 that it should run the extension from the current directory.

We have two ways to activate Zgento_LightBox extension.

  • Run the following console command:

php bin/magento setup:upgrade

Activate_module in Magento 2.0

OR

  • Add our module to the global module list at app/etc/config.php.

You’ll see a PHP include file with a long list of modules. Let’s add our module(add the element: ‘Zgento_LightBox’ => 1,) to the end of the array.

#File: app/etc/config.php
<?php return array ( 'modules' => 
 array (
 'Magento_Store' => 1,
 'Magento_AdvancedPricingImportExport' => 1,
 'Magento_Directory' => 1,
 'Magento_Theme' => 1,
 'Magento_Backend' => 1,
 'Magento_Backup' => 1,
 //............
 'Zgento_LightBox' => 1,
 ),
);

And that’s it! We have successfully created a very simple Magento 2.0 extension. Now go and clear Magento cache, and you’ll see that our extension is working now.

Enable_module_Magento

Thank you so much for following this tutorial. You can also download Zgento_LightBox extension for free by clicking here . 🙂 🙂