Magento – How to add a custom TAB to magento2 product detail

magento2product

I flow How to add a tab in product details page using Magento 2 admin panel step to add a custom tab

and I got this error
enter image description here

my file struct
enter image description here

catalog_product_view.xml

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

    <update handle="catalog_product_opengraph" />
    <update handle="page_calendar"/>
    <body>
        <referenceBlock name="product.info.details">
            <block class="Magento\Catalog\Block\Product\View\Attributes" name="custom.tab" template="product/view/view.phtml" group="detailed_info">
                <arguments>
                    <argument name="title" translate="true" xsi:type="string">Care</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

view.phtml

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

How do I add a custom TAB to magento2 product detail?

Best Answer

I found that adding module can solve this problem

  1. How to add a module?
  2. How to add a custom tab in product detail page