Magento 2 How to Create Custom Product Type.

Hello Guys! 👋

Magento 2 has 6 product types. You should create a new product type for achieving some operation in your store.

By default, Magento provides a simple product, group product, bundle product, configurable product, virtual product, and downloadable product.

The following code helps you to create custom product types in your Magento 2 store.

Step 1: Add product_types.xml file in following path
app\code\Vendor\Extension\etc
<?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="type_new_product" label="Custom Product Type" modelInstance="Vendor\Extension\Model\Product\Type\CustomproductType" indexPriority="40" sortOrder="40" isQty="true">
        <priceModel instance="Vendor\Extension\Model\Product\Price" />
    </type>
</config>

Step 2: Add CustomproductType.php file in following path
app\code\Vendor\Extension\Model\Product\Type
<?php

namespace Vendor\Extension\Model\Product\Type;

class CustomproductType extends \Magento\Catalog\Model\Product\Type\AbstractType {


    public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product)
    {
        // TODO: Implement deleteTypeSpecificData() method.
    }
}

Step 3: Add Price.php file in following path
app\code\Vendor\Extension\Model\Product
&lt;?php

namespace Vendor\Extension\Model\Product;

class Price extends \Magento\Catalog\Model\Product\Type\Price
{


}

Hope! It will help you

Thank you 😊

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 10

No votes so far! Be the first to rate this post.

Leave a Reply

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