Categories
Magento

How to Add Custom Tab in Product Detail page Magento2

In this instructional exercise, I will clarify to how to include custom
tab in product detail page in Magento 2. By default, there are 3 tabs
show in product detail page. Details, More Information & Review Tab. You
must then customise the page if you wish to add extra tabs.
you would like to create new file
app/code/Vendor_Name/Module_Name/view/frontend/layout/catalog_product_view.xml
and paste the underneath code :

<referenceBlock name="product.info.details">
     <block class="Magento\Catalog\Block\Product\View"
         name="custom.tab"
         as="customtab"
         template="Vendor_Module::product/view/custom.phtml"
         group="detailed_info">
         <arguments>
             <argument translate="true" name="title"
 xsi:type="string">Demo Tab</argument>
             <argument name="sort_order" xsi:type="string">10</argument>
         </arguments>
     </block>
</referenceBlock>

After that, ought to make file
app/code/Vendor_Name/Module_Name/view/frontend/templates/product/view/custom.phtml and now add content that custom tab with the content you want to display. Additionally, you can provide the sort order of a custom tab, which will cause it to display in the proper order according to the sort order value you choose.

<span>This is Demo tab</span>


I hope this article on adding a custom tab to
the Magento 2 product detail page is simple to grasp.

If you still have any issue feel free to ask and let me know your views to make the better. Share this solution with your other Magento buddies via social media.

Thanks for reading.

Leave a Reply

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