I have created a custom tab on Magento 2 product page. The custom tab appears at the left side but I want it after detail and review tabs like Details – | – Reviews – | – Custom Tab
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="tab.tab" template="Deno_Mymodule::extra_tab.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Extra Tab</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
Best Answer
If I were you I would consider changing class of your custom block, because you use some existing- block's class - so if you would like to add some more methods to you block class you will have to override magento native class, what is not recommended.
In case, that your tab should be something completely new I would make it with another class inheriting maybe, after
Magento\Catalog\Block\Product\View
.Now something about placing your tab - take a look at
vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml:46
- you have a line:which has name of block, you want your custom one to be after (attribute
name
). Copy that name and add to your xml it like:Although I don't have full code of yours, so I can't test it, please try it and write about results in comment.