Skip to content

Latest commit

 

History

History

NewproductType

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Create New Product Type Programmatically

Goal

  • Add New Product Type Using Model & product_types.xml

newProductType

Step By Step Tutorials

<?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="Bdcrops\NewproductType\Model\Product\Type\NewProductType" indexPriority="60" sortOrder="80" isQty="true">
<priceModel instance="Bdcrops\NewproductType\Model\Product\Price" />
</type>
</config>

<?php
namespace Bdcrops\NewproductType\Model\Product\Type;
class NewProductType extends MagentoCatalogModelProductTypeAbstractType
{
const TYPE_CODE = 'new_product_type';
 public function save($product)
 {
    parent::save($product);
    // your additional saving logic
   return $this;
 }
 public function deleteTypeSpecificData(MagentoCatalogModelProduct $product)
 {
   //your deleting logic
 }
}


<?php
namespace Bdcrops\NewproductType\Model\Product;
class Price extends \Magento\Catalog\Model\Product\Price{
public function getPrice($product) {
//add your logic here return
//some_value;
     }
  }

Ref

biz