Magento2 module development from magento 1

Magento2 module development

Module development was significant process in magento. To built external core functionality or overriding core magento functionality we need to go with modules. Before learning about magento2 module development its important for all to know about the module development. If you are not aware of basic module development structures please visit here. I have listed the important module development changes in magento2. Before moving to Magento 2 module development let see some basic code hint changes in magento 2.

Enabling or disabling the module

In magento1 we disabled module in etc/modules from, from Vendorname_Modulename.xml file by changing true to false. In magento2 the enabling and disabling of module can be done through following commands

php bin/magento module:enable Vendor_Modulename
php bin/magento module:disable Vendor_Modulename

Class names in magento2 module development

In magento 1.x class files of all block, model and controllers are detected from the class names. But in magento 2 the class names not contains the directory structure.
Let us take the example in the given module
Namespace – Explorer
Module name – Test

Magento 1.x

Class Explorer_Test_Block_HeloTitle extends Mage_Core_Block_Template{

Magento 2.x

<?php namespace Explorer\Test\Block;
class HelloTitle extends \Magento\Theme\Block\Html\Title

Get Model in Magento2

To call the model object in module, first there should be a model class file in ‘Model’ directory.

Magento 1.x

Mage::getModel('modulename/modelname') 

Magento 2.x

$object_manager = Magento\Core\Model\ObjectManager::getInstance();
$model = $object_manager->get('Explorer\Test\Model\{Modlename}');
Note: Initiate the object manager class object in _construct function(){

These are some of the hints using class names in magento 2. Some other code snippets click here. Like this change there are huge number of changes in module development structure when compared to magento 1 series. Go through with one by one tops listed below.

The Important topics covered in Magento 2 module development are

  1. Magento2 controllers
  2. Observers in Magento2
  3. Overriding in Magento2
  4. Magento 2 setup script
  5. Magento 2 admin grid

By learning all the above steps, you gain a good knowledge in Magento 2.

One thought on “Magento2 module development from magento 1

Leave a Reply

Your email address will not be published. Required fields are marked *