Reading list Switch to dark mode

    Display Custom Tab On Product View Page – Magento2

    Updated 8 November 2016

    Here we will see how to add new custom tab on product view page in magento2.
    First create file ‘catalog_product_view.xml’ in location ‘Webkul/Test/view/frontend/layout’

    <?xml version="1.0"?>
    <page layout="2columns-left" 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="demo.tab" template="Webkul_Test::demo_tab.phtml" group="detailed_info" >
    				<arguments>
    					<argument translate="true" name="title" xsi:type="string">Demo Tab</argument>
    				</arguments>
    			</block>
    		</referenceBlock>
    	</body>
    </page>

    Now create file ‘demo_tab.phtml’ in location ‘Webkul/Test/view/frontend/templates’ and write content on the file.

    Custom Tab on Product Page

    Custom Tab
    If you want to use product details on this file, you can simply get product by “$product = $block->getProduct();

    <?php
    	// get current product
    	$product = $block->getProduct();
    	echo $product->getName();
    	// Use product according to your requirement
    ?>

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    . . .

    Leave a Comment

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


    1 comments

  • Pankti Shah
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home