Magento 2 – Custom Module


With the official End of life for Magento 1 coming in November 2018 – it is time to start using Magento 2 in order to transition our sites on to the platform well before we have to.

I have said it before and I will continue to say it – there seem to be very few articles about any given task in Magento. There are a couple but you generally have to read all of them and then trial and error to get even the simplest things to work… which is frustrating and makes you wonder whether the authors have tested their code or perhaps that something fundamental has since been changed in Magento and the articles have just not been updated to reflect that.

I have just spent 2 hours attempting to simply install a very basic custom module as the first step of replicating a series of import scripts from M1 to M2.

All this code has been tested at the time of writing and worked with Magento 2.2

Step 1 – Creating your Folders

If this is a fresh Magento 2 install you may well not have a code directory within /app/. If you don’t then simply create it.

a) Create the following folders

  • app/code/Blackrhino
  • app/code/Blackrhino/Import
  • app/code/Blackrhino/Import/etc
  • app/code/Blackrhino/Import/Helper

The Blackrhino folder is the module’s namespace, and Import is the module’s name. I will not claim that all the following files are required to get the module to import but it will certainly work with them (I know this because I have actually tested the code).

b) Now that we have a module folder, we need to create a module.xml file in the app/code/BlackRhino/Import/etc folder with the following code:

c) To register the module, create a registration.php file in the app/code/Blackrhino/Import folder with the following code:

more to follow….

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">