Magento – Magento 2 Change order of Tabs on product page

layoutmagento2product-viewtabs

I have added catalog_product_view.xml in the location app/code/design/frontend/kh/custom/Magento_Catalog/layout

Set the priority for the tabs for the product detail page, but its is not working properly.

Code is given below :

<?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">
            <referenceBlock name="product.info.description">
                <arguments>
                    <argument name="priority" xsi:type="string">4</argument>
                </arguments>
            </referenceBlock>
            <referenceBlock name="product.attributes">
                <arguments>
                    <argument name="priority" xsi:type="string">2</argument>
                </arguments>
            </referenceBlock>
            <referenceBlock name="reviews.tab">
                <arguments>
                    <argument name="priority" xsi:type="string">1</argument>
                </arguments>
            </referenceBlock>
            <block class="KH\Hello\Block\Hello" name="new.tab" template="KH_Hello::hello.phtml" group="detailed_info" >
               <arguments>
                   <argument translate="true" name="title" xsi:type="string">New Tab</argument>
                   <argument name="priority" xsi:type="string">3</argument>
               </arguments>
           </block>
        </referenceBlock>
   </body>
</page>

Best Answer

Try taking that code out the product.info.details referenceBlock. This is my code which is working as intended:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <!-- Reorder tabs (using "before/after" doesn't work with groups) -->
        <referenceBlock name="product.info.description">
            <arguments>
                <argument name="priority" xsi:type="string">10</argument>
            </arguments>
        </referenceBlock>
        <referenceBlock name="reviews.tab">
            <arguments>
                <argument name="priority" xsi:type="string">50</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

The only other difference is this code is using multiples of ten.