Magento 2 Add Custom Tab to Product Page

Magento 2 has a whole new process for adding custom tabs. Gone is the local.xml file as well as the catalog.xml file.
In it’s place, each module has it’s own set of layout files and templates.
In today’s example, we are going to be adding a custom tab to the product view page.
This tab will display different warranty information based on the value of the manufacturer.

The first step is to add the new tab to the catalog_product_view.xml file inside your theme folder.
The folder structure would be app/design/frontend/ThemePackage/Theme/Magento_Catalog/layout/catalog_product_view.xml.
We are going to add the tab via an update to the content block. That tab will call the warranty-info.phtml template.

The warranty-info-template, in turn will check the product’s manufacturer value and display a static block specifically for that manufacturer.
The warranty-info.phtml file will be in the app/design/frontend/ThemePackage/Theme/Magento_Catalog/templates/product/view/ folder.

The Custom Tabs download link below will open a text file with all the layout and template blocks used to make this custom tab.
Custom Tabs (1896)
Good luck!!
If you want to thank us for writing this post, you can buy us a round here and we’ll be eternally thankful.

This entry was posted in Magento, Uncategorized. Bookmark the permalink.