0

I need to show a custom tab after the Review tab on the product detail page. I am using Magento 2.4.3. Below is my code [vendor]/[Module]/view/frontend/layout/catalog_product_view.xml

<?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="Cloudways_Mymodule::custom_tab.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>

[vendor]/[Module]/view/frontend/templates/custom_tab.phtml

<?php

echo "This is Custom tab in product detail page";

?>

Please help me to know what is wrong with the above code as the custom tab is not displaying.

1
  • Please check my answer. magento 2.4.3 there some changes, that's why it's not working. Commented Feb 22, 2022 at 18:44

3 Answers 3

0
<?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="Vendor_Extension::custom_tab.phtml" group="detailed_info">
           <arguments>
              <argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
           </arguments>
        </block>
    </referenceBlock>
</body>
</page>

Confirm this point :

  1. Your extension is register into magento and enable.
1
  • Yes I have checked it is there Commented Dec 30, 2021 at 5:33
0

I did a similar thing using following steps :

Added catalog_product_view.xml in my custom theme

app/design/frontend/Anshu/mytheme/Magento_Catalog/layout

<?xml version="1.0"?>
<page layout="2columns-right" 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\Description" name="product.info.ingredients" template="product/view/ingredients.phtml" group="detailed_info">
                <arguments>
                    <argument name="title" translate="true" xsi:type="string">Ingredients</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

Added ingredients.phtml in

app/design/frontend/Anshu/mytheme/Magento_Catalog/templates/product/view

<?php 
$product = $block->getProduct();
echo $product->getData('ingredients');

I hope this will help you.

0

vendor/magento/module-page-builder/view/frontend/page_layout/product-full-width.xml

Please check this file and comment ->"product.info.details"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.