Adding new tabs on the product view page is a pretty common task. We might need add it accros all products or maybe only one specific one. Here I will show you how to do it for both cases. Also, for this example I assume you already have a custom theme in place.

Adding tab to all products

The first thing we need to do is create the phtml file with the content we want to add. To do so, create a file in app/design/frontend/<YOUR_THEME>/<YOUR_THEME_PACKAGE>/Magento_Catalog/templates/product/view/tab_custom.phtml. Of course you can change this to any folder you want. You can add any content you want to tab_custom.phtml.

Now, lets add the tab to the page. Create, or update if it already exists, the file app/design/frontend/<YOUR_THEME>/<YOUR_THEME_PACKAGE>/Magento_Catalog/layout/catalog_product_view.xml to something like below:

<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <referenceBlock name="product.info.details">
                <block class="Magento\Catalog\Block\Product\View\Description" name="tab.custom" template="product/view/tab_custom.phtml" group="detailed_info">
                    <arguments>
                        <argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
                        <argument name="priority" xsi:type="string">2</argument>
                    </arguments>
                </block>
            </referenceBlock>
            <referenceBlock name="look" remove="true"/>
        </referenceContainer>
    </body>
</page>

Clean your cache with:

$ php bin/magento cache:clean

Now, you should be able to see a new tab on all your products:

Adding tab to a specific product

This one is easy. All you need to do is, on your Back-end, go to Products > Catalog and edit a product. Under the tab Design, on the field “Layout Update XML” add the snippet below. Here I’m using the same phtml file used on the example above.

<referenceContainer name="content">
  <referenceBlock name="product.info.details">
    <block class="Magento\Catalog\Block\Product\View\Description" name="tab.custom" template="product/view/tab_custom.phtml" group="detailed_info">
        <arguments>
            <argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
            <argument name="priority" xsi:type="string">2</argument>
        </arguments>
    </block>
  </referenceBlock>
</referenceContainer>

Save the product and clean the cache. Now the new tab should be showing on the Front-end.

Happy Coding!

https://i2.wp.com/blog.mdnsolutions.com/wp-content/uploads/2016/06/Screen-Shot-2016-06-24-at-10.49.47-AM.png?fit=768%2C391&ssl=1https://i2.wp.com/blog.mdnsolutions.com/wp-content/uploads/2016/06/Screen-Shot-2016-06-24-at-10.49.47-AM.png?resize=150%2C150&ssl=1Renato MedinaMagentoMagento 2Catalog,Magento 2,Product View,Tabs,XMLAdding new tabs on the product view page is a pretty common task. We might need add it accros all products or maybe only one specific one. Here I will show you how to do it for both cases. Also, for this example I assume you already have a...A Magento Craftsman in Melbourne