Quantcast
Channel: Webkul Blog
Viewing all articles
Browse latest Browse all 5537

Add New Product Type – Magento2

$
0
0

Magneto-Code-Snippet
Here we will see how to add own custom product type in magento2.
First create ‘product_types.xml’ file in location Namespace/Module/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="demo" label="Demo Product" modelInstance="Namespace\Module\Model\Product\DemoType" indexPriority="70" sortOrder="70">
	</type>
</config>

After defining product type in ‘product_types.xml’, we need to create model for product type. Now create DemoType.php in location Namespace/Module/Model/Product.

<?php
namespace Namespace\Module\Model\Product;

class DemoType extends \Magento\Catalog\Model\Product\Type\AbstractType
{
    public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product)
    {
    }
}

After this you will see a new product type in admin.
productType


Viewing all articles
Browse latest Browse all 5537