How to Create Custom Product Type in Magento 2?

How to Create Custom Product Type in Magento 2

Default Magento 2 provides 6 product types including simple, grouped, configurable, virtual, bundled and downloadable having unique behaviors and attributes. These standard product types covers majority of the Ecommerce needs by supporting wide range of industry and store owner requirements.

Magento 2 Speed & Performance Optimization Services

But with the diversity of Ecommerce, there may arise a requirement of unique feature that cannot be served by default product types. Luckily you can extend the default product types with the high level of customization. Sometimes it makes complex to work on and still cannot fulfill the business needs where there arises the need to create custom product type in Magento 2.

hyva theme development

Here, I’m going to present complete guide on creating custom product in Magento 2:

Step 1: First, we need to create “product_types.xml” file inside extension the below directory.

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="custom" label="Custom Product" modelInstance="Vendor\Extension\Model\Product\Type\Custom" indexPriority="25" sortOrder="25" isQty="true">
<customAttributes>
<attribute name="default" value="true"/>
</customAttributes>
</type>
</config>

Step 2: Lastly, you need to create “Custom.php” file inside extension the below directory.

app\code\Vendor\Extension\Model\Product\Type

<?php 
namespace Vendor\Extension\Model\Product\Type;

class Custom extends \Magento\Catalog\Model\Product\Type\AbstractType
{
const TYPE_CODE = 'custom';
public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product){

}
}
Hire Magento Programmer
Previous Article

How to Create Order Programmatically in Magento 2

Next Article

How to Create Events Observer in Magento 2?

Write a Comment

Leave a Comment

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

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨