1

I created a custom tab extending catalog_product_view.xml and now I don't know how to order my custom tab, it's displayed the first by default. I want to be displayed after the "Details" tab for example but it's not working the after neither before instructions.

<?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">
    <body>
        <referenceBlock name="product.info.details">
            <block class="Magento\Catalog\Block\Product\View" name="custom.tab" as="custom"
                   template="Vendor_Module::product/custom.phtml" group="detailed_info" after="product.info.description">
                <arguments>
                    <argument translate="true" name="title" xsi:type="string">Custom tab</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

What am I doing wrong? The "Details" tab is named product.info.description right?

I found some solutions, but all consist rewriting all tabs and ordering as you want, but I think it has to be better solutions because rewriting the structure, what will happen if another extension does the same?

2

You can call your block first like this

<block class="Magento\Catalog\Block\Product\View" name="custom.tab" as="custom" template="Vendor_Module::product/custom.phtml" group="detailed_info">
      <arguments>
                <argument translate="true" name="title" xsi:type="string">Custom tab</argument>
      </arguments>
</block>

and then move the same like this

<move element="custom.tab" destination="product.info.details" after="product.info.description" />
1

For Change position of Tabbing in details page, Using xml configuration file after or before attribute not help in this case.

You can see more information from here : Change order of Tabs on product page

1

Magento 2 does not provide any sort order for tab, you can achieve using sequence tag into module.xml file.

<sequence>
    <module name="Magento_Review" />
</sequence>

After that you need to run setup:upgrade command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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