【发布时间】:2019-09-03 02:24:55
【问题描述】:
无法删除特定的块命名:
product.info.options.configurable
在 Magento 2 中。 这是我要更改的布局文件:
vendor/magento/module-configurable-product/view/frontend/layout/catalog_product_view_type_configurable.xml
它的内容是:
<!--
/**
* 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>
<attribute name="class" value="page-product-configurable"/>
<referenceBlock name="head.components">
<block class="Magento\Framework\View\Element\Js\Components" name="configurableproduct_product_view_head_components" template="Magento_ConfigurableProduct::js/components.phtml"/>
</referenceBlock>
<referenceContainer name="product.info.type">
<block class="Magento\ConfigurableProduct\Block\Product\View\Type\Configurable" name="product.info.configurable" as="product_type_data" template="Magento_Catalog::product/view/type/default.phtml"/>
<container name="product.info.configurable.extra" after="product.info.configurable" as="product_type_data_extra" label="Product Extra Info">
<block class="Magento\ConfigurableProduct\Block\Stockqty\Type\Configurable" name="product.info.configurable.extra.catalog_inventory_stockqty_composite" template="Magento_CatalogInventory::stockqty/composite.phtml"/>
</container>
</referenceContainer>
<referenceBlock name="product.info.options.wrapper">
<block class="Magento\ConfigurableProduct\Block\Product\View\Type\Configurable" name="product.info.options.configurable" as="options_configurable" before="-" template="Magento_ConfigurableProduct::product/view/type/options/configurable.phtml"/>
</referenceBlock>
</body>
</page>
如你所见,最后一部分是:
<referenceBlock name="product.info.options.wrapper">
<block class="Magento\ConfigurableProduct\Block\Product\View\Type\Configurable" name="product.info.options.configurable" as="options_configurable" before="-" template="Magento_ConfigurableProduct::product/view/type/options/configurable.phtml"/>
</referenceBlock>
我确信我的代码是正确的:
<referenceBlock name="product.info.options.wrapper" remove="true"/>
可以成功删除包装块,我可以看到它已删除。这向我表明: Magento 是正确的。 我的布局文件由 Magento 读取。 缓存清除工作。 生成的代码清除工作。 我写那一行的方式也有效,因为它确实删除了包装块。 我的操作系统版本、Magento 颠覆、作曲家、IDE、PHP 和其他东西版本也无关紧要,因为删除命令适用于上述块。 但是,当我尝试时:
<referenceBlock name="product.info.options.configurable" remove="true"/>
它只是不起作用。 然后,我将所有可能的行组合删除了我在可以搜索的每个论坛上找到的它,但它仍然没有删除我想要的块:
<referenceBlock name="options_configurable" remove="true"/>
<referenceBlock name="product.info.options.configurable" remove="true"/>
<referenceBlock name="options_configurable" display="false"/>
<referenceBlock name="product.info.options.configurable" display="false"/>
<referenceContainer name="product.info.options.wrapper">
<referenceBlock name="options_configurable" remove="true"/>
<referenceBlock name="product.info.options.configurable" remove="true"/>
<referenceBlock name="options_configurable" display="false"/>
<referenceBlock name="product.info.options.configurable" display="false"/>
</referenceContainer>
<referenceBlock name="product.info.options.wrapper">
<referenceBlock name="options_configurable" remove="true"/>
<referenceBlock name="product.info.options.configurable" remove="true"/>
<referenceBlock name="options_configurable" display="false"/>
<referenceBlock name="product.info.options.configurable" display="false"/>
</referenceBlock>
<referenceContainer name="content">
<referenceBlock name="options_configurable" remove="true"/>
<referenceBlock name="product.info.options.configurable" remove="true"/>
<referenceBlock name="options_configurable" display="false"/>
<referenceBlock name="product.info.options.configurable" display="false"/>
</referenceContainer>
如您所见,我使用了所有可能的选项。块名,别名,remove="true",display="false",内部包装块,内部包装块作为容器,上面的每一行单独,上面的行的组合,等等。
任何想法都受到高度赞赏。提前致谢。
【问题讨论】: