在产品视图 xml 覆盖后删除评论选项卡
Review tab being removed after product view xml override
我遇到一个问题,当我覆盖 catalog_product_view.xml
中的“product.info.details”块时,主题上的评论选项卡被删除
我只是想为产品详细信息和送货信息添加 2 个新标签。这两个完美地工作并出现在我想要的地方,但评论选项卡现在丢失了。
这是我的 catalog_product_view.xml:
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<move element="page.main.title" destination="product.info.main" before="-"/>
<move element="product.info.main" destination="product.main.content" after="product.info.media"/>
<move element="product.info.media" destination="product.main.content" before="-"/>
<move element="product.info.details" destination="product.info.main" after="product.info.main"/>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Product\View\Details" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" as="description" template="Magento_Catalog::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">Details</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="Magento_Catalog::product/view/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">20</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="product.info.productdetails" as="productdetails" template="Magento_Catalog::product/view/product_details.phtml" group="detailed_info" after="product.info.description">
<arguments>
<argument name="title" translate="true" xsi:type="string">Product Details</argument>
<argument name="sort_order" xsi:type="string">30</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="product.info.deliveryinfo" as="deliveryinfo" template="Magento_Catalog::product/view/delivery_info.phtml" group="detailed_info" after="product.info.description">
<arguments>
<argument name="title" translate="true" xsi:type="string">Delivery Information</argument>
<argument name="sort_order" xsi:type="string">40</argument>
</arguments>
</block>
</block>
</referenceContainer>
<referenceContainer name="content">
<container name="product.main.content" htmlTag="div" htmlClass="product-main-content" before="-">
</container>
</referenceContainer>
</body>
</page>
这是页面上的结果:
xml 我是否遗漏了什么,如果我删除覆盖并使用基本的 Magento 代码,它会回到原来的位置。
好的,我找到了解决方案。只是我不够细心。我需要将 product.info.details 块放入我为其制作的容器中...
如果有人感兴趣,这应该是这样的:
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<move element="page.main.title" destination="product.info.main" before="-"/>
<move element="product.info.main" destination="product.main.content" after="product.info.media"/>
<move element="product.info.media" destination="product.main.content" before="-"/>
<move element="product.info.details" destination="product.info.main" after="product.info.main"/>
<referenceContainer name="content">
<container name="product.main.content" htmlTag="div" htmlClass="product-main-content" before="-">
<block class="Magento\Catalog\Block\Product\View\Details" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" as="description" template="Magento_Catalog::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">Details</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="Magento_Catalog::product/view/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">20</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="product.info.productdetails" as="productdetails" template="Magento_Catalog::product/view/product_details.phtml" group="detailed_info" after="product.info.description">
<arguments>
<argument name="title" translate="true" xsi:type="string">Product Details</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="product.info.deliveryinfo" as="deliveryinfo" template="Magento_Catalog::product/view/delivery_info.phtml" group="detailed_info" after="product.info.description">
<arguments>
<argument name="title" translate="true" xsi:type="string">Delivery Information</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
</block>
</container>
</referenceContainer>
</body>
</page>
我遇到一个问题,当我覆盖 catalog_product_view.xml
中的“product.info.details”块时,主题上的评论选项卡被删除我只是想为产品详细信息和送货信息添加 2 个新标签。这两个完美地工作并出现在我想要的地方,但评论选项卡现在丢失了。
这是我的 catalog_product_view.xml:
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<move element="page.main.title" destination="product.info.main" before="-"/>
<move element="product.info.main" destination="product.main.content" after="product.info.media"/>
<move element="product.info.media" destination="product.main.content" before="-"/>
<move element="product.info.details" destination="product.info.main" after="product.info.main"/>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Product\View\Details" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" as="description" template="Magento_Catalog::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">Details</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="Magento_Catalog::product/view/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">20</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="product.info.productdetails" as="productdetails" template="Magento_Catalog::product/view/product_details.phtml" group="detailed_info" after="product.info.description">
<arguments>
<argument name="title" translate="true" xsi:type="string">Product Details</argument>
<argument name="sort_order" xsi:type="string">30</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="product.info.deliveryinfo" as="deliveryinfo" template="Magento_Catalog::product/view/delivery_info.phtml" group="detailed_info" after="product.info.description">
<arguments>
<argument name="title" translate="true" xsi:type="string">Delivery Information</argument>
<argument name="sort_order" xsi:type="string">40</argument>
</arguments>
</block>
</block>
</referenceContainer>
<referenceContainer name="content">
<container name="product.main.content" htmlTag="div" htmlClass="product-main-content" before="-">
</container>
</referenceContainer>
</body>
</page>
这是页面上的结果:
xml 我是否遗漏了什么,如果我删除覆盖并使用基本的 Magento 代码,它会回到原来的位置。
好的,我找到了解决方案。只是我不够细心。我需要将 product.info.details 块放入我为其制作的容器中...
如果有人感兴趣,这应该是这样的:
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<move element="page.main.title" destination="product.info.main" before="-"/>
<move element="product.info.main" destination="product.main.content" after="product.info.media"/>
<move element="product.info.media" destination="product.main.content" before="-"/>
<move element="product.info.details" destination="product.info.main" after="product.info.main"/>
<referenceContainer name="content">
<container name="product.main.content" htmlTag="div" htmlClass="product-main-content" before="-">
<block class="Magento\Catalog\Block\Product\View\Details" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" as="description" template="Magento_Catalog::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">Details</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="Magento_Catalog::product/view/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">20</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="product.info.productdetails" as="productdetails" template="Magento_Catalog::product/view/product_details.phtml" group="detailed_info" after="product.info.description">
<arguments>
<argument name="title" translate="true" xsi:type="string">Product Details</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View" name="product.info.deliveryinfo" as="deliveryinfo" template="Magento_Catalog::product/view/delivery_info.phtml" group="detailed_info" after="product.info.description">
<arguments>
<argument name="title" translate="true" xsi:type="string">Delivery Information</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
</block>
</container>
</referenceContainer>
</body>
</page>