Skip to main content
  1. First go to the admin panel of your Magento store and then navigate to Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)

  2. Now go to Stores -> Attribute Set and Add Attribute Set.

  3. Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.

  4. Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.

  5. In app/code/Test/ProductTabs/etc/module.xml paste this code. `

  
<?xml version="1.0"?>
   <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
   <module name="Test_ProductTabs" setup_version="1.0.0"></module>
</config>
`
  1. In app/code/Test/ProductTabs/registration.php, paste this code. `
Custom Tab `
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Test_ProductTabs',
    __DIR__
);
  1. In app/code/Test/ProductTabs/view/frontend/layout/catalog_product_view.xml, paste this 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.info.details">
            <block class="Magento\Catalog\Block\Product\View" name="demo.tab" template="Test_ProductTabs::custom_tab.phtml" group="detailed_info" >
                <arguments>
                    <argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>
  1. Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code. `
getProduct(); ?> getData('demo'); ?> `
<?php 
$product = $block->getProduct();
?>
 <h1 style="color: #00aeed"><?php echo $product->getData('demo'); ?></h1>  
  1. Now lauch your product page.
  1. First go to the admin panel of your Magento store and then navigate to Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)

  2. Now go to Stores -> Attribute Set and Add Attribute Set.

  3. Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.

  4. Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.

  5. In app/code/Test/ProductTabs/etc/module.xml paste this code. `

 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
`
  1. In app/code/Test/ProductTabs/registration.php, paste this code. `
Custom Tab `
  1. Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code. `
getProduct(); ?> getData('demo'); ?> `
  1. Now lauch your product page.
  1. First go to the admin panel of your Magento store and then navigate to Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)

  2. Now go to Stores -> Attribute Set and Add Attribute Set.

  3. Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.

  4. Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.

  5. In app/code/Test/ProductTabs/etc/module.xml paste this code.

 
<?xml version="1.0"?>
   <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
   <module name="Test_ProductTabs" setup_version="1.0.0"></module>
</config>
  1. In app/code/Test/ProductTabs/registration.php, paste this code.
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Test_ProductTabs',
    __DIR__
);
  1. In app/code/Test/ProductTabs/view/frontend/layout/catalog_product_view.xml, paste this 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.info.details">
            <block class="Magento\Catalog\Block\Product\View" name="demo.tab" template="Test_ProductTabs::custom_tab.phtml" group="detailed_info" >
                <arguments>
                    <argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>
  1. Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code.
<?php 
$product = $block->getProduct();
?>
 <h1 style="color: #00aeed"><?php echo $product->getData('demo'); ?></h1>  
  1. Now lauch your product page.
added 169 characters in body
Source Link
  1. First go to the admin panel of your Magento store and then navigate to Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)

  2. Now go to Stores -> Attribute Set and Add Attribute Set.

  3. Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.

  4. Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.

  5. In module.xmlapp/code/Test/ProductTabs/etc/module.xml paste this code. `

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
`
  1. In registration.phpapp/code/Test/ProductTabs/registration.php, paste this code. `
Custom Tab `
  1. Now in custom_tab.phtmlapp/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code. `
getProduct(); ?> getData('demo'); ?> `
  1. Now lauch your product page.
  1. First go to the admin panel of your Magento store and then navigate to Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)

  2. Now go to Stores -> Attribute Set and Add Attribute Set.

  3. Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.

  4. Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.

  5. In module.xml paste this code. `

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
`
  1. In registration.php, paste this code. `
Custom Tab `
  1. Now in custom_tab.phtml, paste this code. `
getProduct(); ?> getData('demo'); ?> `
  1. Now lauch your product page.
  1. First go to the admin panel of your Magento store and then navigate to Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)

  2. Now go to Stores -> Attribute Set and Add Attribute Set.

  3. Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.

  4. Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.

  5. In app/code/Test/ProductTabs/etc/module.xml paste this code. `

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
`
  1. In app/code/Test/ProductTabs/registration.php, paste this code. `
Custom Tab `
  1. Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code. `
getProduct(); ?> getData('demo'); ?> `
  1. Now lauch your product page.
Source Link

  1. First go to the admin panel of your Magento store and then navigate to Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)

  2. Now go to Stores -> Attribute Set and Add Attribute Set.

  3. Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.

  4. Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.

  5. In module.xml paste this code. `

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
`
  1. In registration.php, paste this code. `
Custom Tab `
  1. Now in custom_tab.phtml, paste this code. `
getProduct(); ?> getData('demo'); ?> `
  1. Now lauch your product page.