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

Add Product Tab For Specific Product Type In Your Custom Module Magento 2

$
0
0

Add Product Tab For Specific Product Type In Your Custom Module Magento 2 – Here I’m going to explain you how you can add custom product tab for specific product type in your custom module.
STEP – 1

  1. Create “catalog_product_simple.xml” File. // If you want to show that tab for “simple” product type.
  2. Create “catalog_product_configurable.xml” File. // If you want to show that tab for “configurable” product type.
  3. Create “catalog_product_grouped.xml” File. // If you want to show that tab for “grouped” product type.
  4. Create “catalog_product_virtual.xml” File. // If you want to show that tab for “virtual” product type.
  5. Create “catalog_product_bundle.xml” File. // If you want to show that tab for “bundle” product type.
  6. Create “catalog_product_downloadable.xml” File. // If you want to show that tab for “downloadable” product type.
  7. Create “catalog_product_new.xml and catalog_product_new.xml” File. // If you want to show that tab for all product type.

In File Location Vendor/CustomModule/view/adminhtml/layout.

STEP-2
Add below code.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="product_form">
            <block class="Vendor\CustomModule\Block\Adminhtml\Catalog\Product\Edit\Tab\CustomTab" name="custom.tab">
                <arguments>
                    <argument name="config" xsi:type="array">
                        <item name="label" xsi:type="string" translate="true">Custom Tab</item>
                        <item name="collapsible" xsi:type="boolean">true</item>
                        <item name="opened" xsi:type="boolean">true</item>
                        <item name="sortOrder" xsi:type="string">2</item>
                        <item name="canShow" xsi:type="boolean">true</item>
                        <item name="componentType" xsi:type="string">fieldset</item>
                    </argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

STEP-3
Now create file “CustomTab.php” in location Vendor\CustomModule\Block\Adminhtml\Catalog\Product\Edit\Tab

<?php
namespace Vendor\CustomModule\Block\Adminhtml\Catalog\Product\Edit\Tab;
 
class CustomTab extends \Magento\Framework\View\Element\Template
{
    /**
     * @var string
     */
    protected $_template = 'customtab.phtml';
 
}

STEP-4
In last create template file “customtab.phtml” in loction Vendor/CustomModule/view/adminhtml/templates

Custom tab content...................

downloadable-product-tab

In this way you can add tabs for specific type product and If you have any query then write comment below.


Viewing all articles
Browse latest Browse all 5554

Trending Articles