Reading list Switch to dark mode

    Add New Product Type – Magento2

    Updated 19 November 2016

    We can create and add new product type in magento2.
    In this blog we will see how to add own product type in magento2.

    New Product Type Declaration

    First of all 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.
    Finally 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.
    New Product Type

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    . . .

    Leave a Comment

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


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home