0

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>
0

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.

| improve this answer | |
  • 1
    I used same code as you provided but no luck. I am using Magento2.2 version. If I tried to pass additional argument like <argument name="title" xsi:type="string">New Review</argument> It display title of Review tab to New Review. – Kishor Hase Nov 8 '17 at 6:18
0

Moving the code out of product.info.details worked, and also applying it to a referenceBlock rather than the actual block in product.info.details. So mine now looks something like

<referenceBlock name="product.info.details">
    <referenceBlock name="product.info.description" remove="true" />
    <block class="Magento\Catalog\Block\Product\View" name="custom_template.tab" before="-" template="product/view/custom_template.phtml" group="detailed_info" >
        <arguments>
            <argument translate="true" name="title" xsi:type="string">About</argument>
        </arguments>
    </block>
    <block class="Magento\Catalog\Block\Product\View" name="product.info.composition" after="-" template="product/view/attribute.phtml" group="detailed_info" >
        <arguments>
            <argument name="at_call" xsi:type="string">getComposition</argument>
            <argument name="at_code" xsi:type="string">composition</argument>
            <argument name="css_class" xsi:type="string">composition</argument>
            <argument name="at_label" xsi:type="string">none</argument>
            <argument translate="true" name="title" xsi:type="string">Nutrition</argument>
        </arguments>
    </block>
</referenceBlock>

<!-- PRIORITY WORKS HERE -->
<referenceBlock name="custom_template.tab" template="product/view/custom_template.phtml" >
    <arguments><argument name="priority" xsi:type="string">1</argument></arguments>
</referenceBlock>
<referenceBlock name="product.info.composition" template="product/view/attribute.phtml" >
    <arguments><argument name="priority" xsi:type="string">2</argument></arguments>
</referenceBlock>
<referenceBlock name="reviews.tab">
    <arguments><argument name="priority" xsi:type="string">3</argument></arguments>
</referenceBlock>
| improve this answer | |

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.