How to Create a Custom Product Type and Specific Import/Export in Magento 2

Nov 22, 2016804
How to Create a Custom Product Type and Specific Import/Export in Magento 2

In the following article I would like to share my experience of Custom Product Type creation and I’d like to guide you how to import it to the system in specific way.

Sometimes we are facing some extraordinary needs of our clients about product types, and these types are easy to create by observer or default product types. But sometimes there is no way, except of creating your own type of product. For example it could be applied to gift cards or other types of VIP cards.

I won’t tell you about creating a new module from scratch (this info you can find from another source), so let’s get into the basic part:

Let’s say you’ve already created a module and the first thing we have to do is to add a file with description of a new type of product: <Vendor_Name>/<Module_Name>/etc/product_types.xml


You can specify such attributes:

  • name: new product code
  • label: product name
  • modelInstance: new product model
  • indexPriority: priority index
  • isQty: whether it has a quantity
  • sortOrder: position number in sort list
  • canUseQtyDecimals: whether the quantity is fractional

Also we are capable to override such internal models:

  • priceModel: model of a price
  • indexerModel: model of indexing logic
  • stockIndexerModel: model of stock indexing


Or we can add custom attributes:


So now let’s take a look at class content. First of all:



Custom model of the price:



We created primary files for a new product. Now we should initialize it into the system. And for that we must describe process of installation of the module.



Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Vlad

How to Create a Custom Product Type and Specific ImportExport in Magento 2

Perfect! A new product is done. And now if you want to fill your store with new products, what should you do?

Further I am going to describe a process of creating a custom import of our new products. First of all we must create the file:


  • entity: EAV import model
  • name: import code
  • model: data processing model

In the current xml file we describe import model and its relations, for example reindexing trigger after import.

Below is the import model that could be inherited by abstract class


Data export process looks rather similar. We describe export.xml file, it has the same content, but refer to export models and export class of our type.

Well, I think that’s all. Thanks for reading this brief guide and I hope it will be helpful in the process of creating new products and import.

Here is an example of the module.

Partner With Us Looking for a partner that will help you to grow your business? We are the right company to develop your webstore. Feel free to get in touch with us. We will be happy to discuss your business opportunities and provide you with a Free Quote. Talk to Vlad


Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *