【问题标题】:Review tab being removed after product view xml override在产品视图 xml 覆盖后删除评论选项卡
【发布时间】:2021-07-02 14:21:45
【问题描述】:

我遇到了一个问题,当我覆盖 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 代码,它会出现在原来的位置。

【问题讨论】:

    标签: xml magento2


    【解决方案1】:

    好的,我找到了解决方案。只是我不够细心。我需要将 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多