How to add number of custom tab in product info detail tab?
-
05-03-2021 - |
题
I added 3 custom tab in product info detail tab page
<referenceBlock name="product.info.details">
<block class="Magento\Catalog\Block\Product\View" name="custom1.tab" as="custom1" template="product/view/custom1.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">custom1</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="custom2.tab" as="custom2" template="product/view/custom2.phtml" group="custom2" >
<arguments>
<argument translate="true" name="title" xsi:type="string">custom2</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="custom3.tab" as="custom3" template="product/view/custom3.phtml" group="custom3" >
<arguments>
<argument translate="true" name="title" xsi:type="string">custom3</argument>
</arguments>
</block>
</referenceBlock>
and i call .phtml in seperate files. Frontend gets only "custom3" tab which i placed in last line in .xml file.
Please let me know the corrections in this file
解决方案
Please try this way :-
<referenceBlock class="Magento\Catalog\Block\Product\View\Details" name="product.info.details" template="Magento_Catalog::product/view/details.phtml">
<block class="Magento\Catalog\Block\Product\View" name="custom1.tab" as="custom1" template="product/view/custom1.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">custom1</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="custom2.tab" as="custom2" template="product/view/custom2.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">custom2</argument>
<argument name="sort_order" xsi:type="string">20</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="custom3.tab" as="custom3" template="product/view/custom3.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">custom3</argument>
<argument name="sort_order" xsi:type="string">30</argument>
</arguments>
</block>
</referenceBlock>
add
group="detailed_info"
in all tab