How To Create Your Own Magento 2 Module How To Create Your Own Magento 2 Module

Magento community has been speaking a lot about Magento 2 recently. And most likely you are already well aware of Magento 2 directory and file structure as well as about modules installation. Maybe you even tried to create your own module on Magento 2.

In this article I will describe a simple Magento 2 module creator that will help you to generate a module prototype based on the company name and the module name and compose module templates in a couple of clicks. The script creates basic XML configuration and PHP files for the module, so developers don’t have to worry about generating all these files for their custom module. The creator adds a separate tab with a simple table to the admin panel which allows you to easily create and edit items.


Module components:

  • Items Model is used for creating, editing or deleting module items.
  • Cron Model is used for implementing various cron options.
  • Block and Controller Adminhtml/Items are used for displaying the elements of the Item collection in admin panel.


How to setup:

  • Insert your company name, the name for the module and your contact email in the form. After that module package will be generated and sent to your email;
  • Get the installation package on your email;



  • Install the module:

a) Unpack the extension ZIP file on your computer.

b) Connect to your website source folder with FTP/SFTP/SSH client and upload all the files and folders from the extension package to the corresponding root folder of your Magento installation: Please use the “Merge” upload mode. Do not replace the whole folders, but merge them. This way your FTP/SFTP client will only add new files. This mode is used by default by most of FTP/SFTP clients software. For MacOS it’s recommended to use Transmit.


c) Connect to your Magento directory with SSH.

d) Run the following commands:

php bin/magento module:enable Amasty_Modulename

user@55m:/var/www/store$ php/magento module:enable Amasty_Promo

php bin/magento setup:upgrade

user@55m:/var/www/store$ php bin/magento setup:upgrade


e) Go to System — Cache Management page on your Magento backend and click the “Flush Magento Cache ” button. After this action, the extension is installed.


What the creator does:

  • This script will create module for Magento 2.
  • It will create table named as “namespace_modulename”.
  • It will provide all basic features for admin user such as Add, Update and Delete.


How to get it:

If you’d like to start using the module creator, just visit Amasty website.


Instead of a conclusion

In case you want to contribute to the project and create custom variants of the script like creator improvements and updates, please visit GitHub website where you can find program source code and detailed description. Otherwise, you can contact Magento 2 creator developer– Amasty team via email.



No comments so far.

Be first to leave comment below.