0

I am trying to swap two tabs around, Product Details and Specification. I want Specification tab to show up first and then Product Details tab.

I already did some research on stackExchange and add the After="" tag but its not working.

<block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="product/view/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">SPECIFICATIONS</argument>
</arguments>
</block>

<block class="Magento\Catalog\Block\Product\View\Description" after="product.attributes" name="product.info.description" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getDescription</argument>
<argument name="at_code" xsi:type="string">description</argument>
<argument name="css_class" xsi:type="string">description</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Product Details</argument>
</arguments>
</block>
0

In Magento 2.3, they have added a sort-order to the tab block definitions that you set in layout XML. In the meantime, while continuing to use 2.2, you will have to do some custom code, as the "before" and "after" directives don't work for this. I recommend you reference this Inchoo blog post: https://inchoo.net/magento-2/customising-product-info-tabs-magento-2-part-2/

  • Thank you , I cannot find details.phtml under /Magento_Catalog/templates/product/view. My theme does not use "details.phtml" it has its own file called "attribute.phtml" however there is one details.phtml file but its under Magento_Catalog/templates/product/view/type I am not sure where should I place this code " $detailedInfoGroup = ["reviews.tab", "product.info.description", "product.attributes"]" – Akram Oct 14 at 12:44
0

Use priority tag like below

<arguments>
    <argument name="priority" xsi:type="string">REPLACE WITH SOME NUMBER</argument>
</arguments>

example code

<referenceBlock name="product.info.details">
        <referenceBlock name="product.info.description">
            <arguments>
                <argument name="priority" xsi:type="string">1</argument>
            </arguments>
        </referenceBlock>
        <referenceBlock name="product.attributes">
            <arguments>
                <argument name="priority" xsi:type="string">3</argument>
            </arguments>
        </referenceBlock>
        <referenceBlock name="reviews.tab">
            <arguments>
                <argument name="priority" xsi:type="string">2</argument>
            </arguments>
        </referenceBlock>
    </referenceBlock>
  • Where should I add this ? under catalog_product.xml ? then where should I place this code under ? container name="product.info.options.wrapper.common" label="Product Options" after="product.row.main.detail"/> or <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.details" template="product/view/details.phtml"> – Akram Oct 14 at 11:43
  • Yes you need to update your themes's Magento_Catalog/layout/catalog_product.xml and you can put above code after product.info.media container – Narayan Jat Oct 14 at 17:17

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.