O'Reilly logo

Magento 2 - Build World-Class online stores by Jonathan Bownds, Bret Williams, Vladimir Kerkhoff, Ray Bogman, Fernando J. Miguel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating your own product type

In Magento 2, it is easy to add your own product type, which can be useful when you want to add some special features that are not available through the default product types. In this recipe, we will see a minimal new product type that calculates the price based on the cost of the product; you can easily extend it further to fit your own needs.

Getting ready

Every product type has its own unique code specified, and it's important to use a short code to identify your product type.

How to do it…

The following steps in this recipe show you how to create a (minimal) new product type:

  1. First, we need to declare the new product type:

    etc/product_types.xml

    <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required