MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

Methods to pack a Magento extension

Published on 31 August 16
1
3

Magento tutorial for newbies perceive that Magento 2 will likely be released in a near future, so it's essential to develop modules for the new system. To resolve this case, we provide you with this attention-grabbingMagento extension tutorial, which compare Magento 1 and Magento 2 in some options under, and provide you with a step-by-step tutorial about making a easy module in Magento 2. Let’s begin!

>>>> View extra : https://www.magebay.com/magento-2-extensions - Magento Marketplace

1. Differences between Magento 1.zero and Magento 2.0

This can be a table which compare Magento 1 and Magento 2 in lots of options:

Magento 1.0Magento 2.zero
Folder app/code consists of subfolders: core, group, nativeFolder app/code consists of subfolders Magento and Zend. In Magento 1.0, Magento andZend are subfolders of the folder core
Codes created by builders are located at app/code/native or app/code/neighborhoodCodes created by developers are written straight in app/code. There is no such thing as a difference between local and community
Module declaration file is a xml file in app/and many others/modulesEg: Module Checkout in Magento Core is asserted in app/and so forth/modules/Mage_All.xmlModule declaration file is at all times module.xml which is written on to folder and so on in the moduleEg: module Checkout in Magento Core is asserted in app/code/Magento/Checkout/etc/module.xml
Layout and template are saved in folder app/designEg: app/design/frontend/default/default/structureLayout and template are saved in the folder View in the module. The folder is similar stage with some folders like: Block, Controller, Helper, Mannequin, etc. in the moduleEg: app/code/Magento/Hey/view/frontend/structure

Above are some fundamental variations between Magento 1.0 and Magento 2.0 so that you could simply visualize the folder construction in Magento 2.0. Thus, making a simple module in Magento 2.zero is just a breeze. For deeper understand, transfer to the subsequent half & follow.

2. Create a simple module in Magento 2.0

(Namespace: Magento, Module Name: Hiya)

Instance link on native host: http://localhost/magento20/hi there/index/index

Step 1: Write the file module.xml in app/code/Magento/Howdy/and so on/module.xml to declare the module.

title="Magento_Hello" schema_version="zero.zero.1"/> 

Methods to pack a Magento extension - Image 1

Step 2:

– Create controller and motion:

– Create the file Index.php inapp/code/Magento/Hello/Controller/Index/Index.php

Folder Index performs the position of controller, whereas Index.php is action. The chief operate of action Index is execute()

namespace MagentoHelloControllerIndex; class Index extends MagentoFrameworkAppActionAction  public perform execute()  $this->_view->loadLayout(); $this->_view->getLayout()->initMessages(); $this->_view->renderLayout();  

Methods to pack a Magento extension - Image 2

– Create a Block: app/code/Magento/Whats up/Block/Good day.php

app/code/Magento/Hiya/Block/Whats up.php namespace MagentoHelloBlock; class Hiya extends MagentoFrameworkViewElementTemplate  public function _prepareLayout()  return guardian::_prepareLayout();  

Methods to pack a Magento extension - Image 3

– Write configuration file: /app/code/Magento/Good day/and so forth/frontend/routes.xml

– In Magento 1.zero, every information about router, events of frontend and backend is asserted in Magento/Hey/etc/config.xml. Nevertheless, in Magento 2.zero, file config.xml only configures the default configuration worth in tag

+) Information about router of frontend shall be reported in:

Magento/Hello/and so on/frontend/routes.xml (it's just like backend)

+) Occasion of frontend can be declared in: Magento/Hi there/ect/frontend/events.xml (it's similar to backend)

In the scope of a simple module, we solely declare routers in Magento/Hiya/etc/frontend/routes.xml

title="Magento_Hello" /> 

Methods to pack a Magento extension - Image 4

Step three: Create a Frontend Template

– Write a format file: appcodeMagentoHelloviewfrontendlayouthello_index_index.xml

Name of structure file is admittedly necessary in this step. Will probably be named after the construction: router name_controlle namer_action identify

<web page xmlns:xsi="http://www.w3.org/2001/XMLSchema-occasion" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Structure/and many others/page_configuration.xsd"> <physique> identify="content"> title="good day" template="success.phtml"> body> page>

Methods to pack a Magento extension - Image 5

Then, we create a file success.phtml as reporting in layout file:

appcodeMagentoHelloviewfrontendtemplatessuccess.phtml


  1. Successful! This is a simple module in Magento 2.0′; ?>

Methods to pack a Magento extension - Image 6

Step 4: Activate Magento_Hello extension in configuration file

– Open the file app/and so forth/config.xml

In the array ‘module’, add the factor: ‘Magento_Hello’ => 1,

Methods to pack a Magento extension - Image 7

You might have identified all of the steps to put in writing a easy module in Magento 2.zero. When you run the hyperlink: http://localhost/magento20/whats up/index/index the outcome will be proven as the next:

Methods to pack a Magento extension - Image 8

That is magento tutorial of how to create a easy module in Magento 2.zero. Hope you guys like my tutorial.
This blog is listed under Development & Implementations and E-Commerce Community

Related Posts:
View Comment (1)
Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
  1. 01 September 16
    0

    Thank you for sharing. Its very informative and detailed. Does the custom extension build for magento need to go through magento approval process or we can simply integrate and share with the open soure community?

You may also be interested in
 
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top