Create a new Module in Magento
single,single-post,postid-16775,single-format-standard,,-,ajax_fade,page_not_loaded,qode-theme-ver-5.9,wpb-js-composer js-comp-ver-4.3.4,vc_responsive

Create a new Module in Magento


06 Aug Create a new Module in Magento

Create a new Module in  Magento

In the architecture magento we know that all of Magento functions are modules in other words Magento is a set of modules perform different tasks. In this article I will guide you to create a new module is full of key components called “Hello World”.

Note – All of the demo module is written in the local folder because magento will surely make new version and if so, the code in each local directory update my code has not been affected.

Before going into the main theme remains all we need to disable the cache for every change on the new module will be displayed on the website without the need to refresh  cache.

Visit: Admin -> System -> Cache Management then select all cache and disable them.

Ok has completed the preparation and now we will start to create a module named “Hello World” to the namespace as “Sulopa”. As this is the first module, so I will do the most simple so that you can understand. This module is responsible for printing out the text “Hello world!” Outside the frontend.

Step 1: Create the main folder for module

First I will create a hierarchy of folders required







Step 2: Create the configuration file for the module with the name “Sulopa_Helloworld.xml” in the folder app / etc / modules

This file declarations with effect magento codePool system and the status of the module:

  • codePool: local (code placed in a local directory and not community or core).
  • active: true (module is active).

Step 3: Create the config.xml file in the folder “app\code\local\Sulopa\HelloWorld \ etc” to declare the components of the module in system magento

In this config files we have declared some of the information for the module:

  • version: 1.0 – version of module current is 1.0
  • Block bookings of module directory is “app/code/local/Sulopa/HelloWorld/Block”
  • frontName or router or on the frontend is helloworld
  • frontend layout file is helloworld.xml

Step 4: write block helloword

File Helloworld.php in the folder “app /code/local/Sulopa/HelloWorld /Block”

Step 5: Create a template file helloworld.phtml

in the folder “app / design / frontent / base / default / template / helloworld” with content

Step 6: Create helloworld.xml layout files in the folder: 


Step 7: Create the folder controller IndexController.php 


Why are we again named controller index? When users hit 1 shortened link on the browser “” will be missing controller name and action name. In this case the system will know take the default controller and take action IndexController indexAction default.

In the above  action index includes only two commands:

+ $ This-> loadLayout (): used to load layout, block, template from the layout file

+ $ This-> renderLayout (): render the interface between the block, according to the order template has been preset in the file layout

So we just finished the first module on the Magento open source. Now we will see the result!

+ Copy source code to install magento directory

+ Disable / refresh caches before running

Results show:


hope this article will help you, thanks!


Jenny Tran
No Comments

Post A Comment