cancel
Showing results for 
Search instead for 
Did you mean: 

how to Show data in the tab of product detail page

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

how to Show data in the tab of product detail page

I have to do same work as detail tab is doing on product detail page . I have added a tab named as technical details on product detail page. Also I have added technical detail section for each product on backend. Now I want to show the data of technical detail in the tab of product detail page. kindly tell me what I have to do ??technicaldeatils.PNG tab.PNG

1 ACCEPTED SOLUTION

Accepted Solutions

Re: how to Show data in the tab of product detail page

Hello @mehreen_hanif 

 

Create layout/catalog_product_view.xml in a custom module or in theme

 

Add the following 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="test.tab" template="Custom_Module::custom_tab.phtml" group="detailed_info" >
               <arguments>
                   <argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
               </arguments>
           </block>
       </referenceBlock>
   </body>
</page>

Create custom_tab.phtml in same custom module or theme

 

<?php
$product = $block->getProduct();
?>
<h1 style="color: #1979c3"><?php echo $product->getData('attribute name'); ?></h1>

Hope it helps.

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

View solution in original post

1 REPLY 1

Re: how to Show data in the tab of product detail page

Hello @mehreen_hanif 

 

Create layout/catalog_product_view.xml in a custom module or in theme

 

Add the following 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="test.tab" template="Custom_Module::custom_tab.phtml" group="detailed_info" >
               <arguments>
                   <argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
               </arguments>
           </block>
       </referenceBlock>
   </body>
</page>

Create custom_tab.phtml in same custom module or theme

 

<?php
$product = $block->getProduct();
?>
<h1 style="color: #1979c3"><?php echo $product->getData('attribute name'); ?></h1>

Hope it helps.

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"