This new product type will contain parent informations of other products. These products are only for internal use, so I only need to add attributes and a new type of relation to other products, like Up-Sells, Cross-Sells. All other default informations like prices, description, etc. are not needed.

What is the best way to create this product type.


1 Answer 1


Step 1: Generate the app\code\Vendor\Module\registration.php file

Setup the app\code\Vendor\Module\registration.php file


Generate the app\code\Vendor\Module\etc\module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0">


Next, the creation of the etc/product_types.xml file is necessary to determine the model of the new product type.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd">
    <type name="new_product_type" label="New Product Type" modelInstance="Vendor\Module\Model\Product\Type\NewProductType" indexPriority="60" sortOrder="80" isQty="true">
        <priceModel instance="Vendor\Module\Model\Product\Price" />

Step 2: Enter the code : Vendor\Module\Model\Product\Type\NewProductType model

Enter the code below: Vendor\Module\Model\Product\Type\NewProductType model, that should be based on Magento\Catalog\Model\Product\Type\AbstractType.


namespace Vendor\Module\Model\Product\Type;

class NewProductType extends \Magento\Catalog\Model\Product\Type\AbstractType 


After that, it is possible to rewrite some functions and implement some changes you want there.

Step 3: Enter the Vendor\Module\Model\Product\Price model

Enter Vendor\Module\Model\Product\Price model, which should be based on the Magento\Catalog\Model\Product\Type\Price.

 namespace Vendor\Module\Model\Product;
 class Price extends \Magento\Catalog\Model\Product\Type\Price


Besides, you can also set the new product type as versatile type with some custom functions after extending the Magento\Catalog\Model\Product\Type\Price class

Step 4: Public the new Magento 2 Product type

This is the step allowing you to check the result in the Magento 2 Administrator when completing the above steps. The New Product type will display as the old types (Simple or Configurable Product).

I hope this will help

  • Thank you, I will try it Mar 15, 2019 at 7:45
  • @christian if it's helpful then please mark my answer correct and upvote my answer so it helps other readers as well. Keep coding 👍 Mar 15, 2019 at 8:55
  • I followed your expalnation, but I get an Error when I run the setup/update command: There are no commands defined in the "setup" namespace. Mar 16, 2019 at 2:18
  • I edited my answer in step 3 price model there is issue in the namespace please again copy and paste the code of step3. Mar 16, 2019 at 3:46
  • @christian then please mark my answer correct it helps other readers as well. Keep coding 👍 Mar 16, 2019 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.