2017-01-13 11 views
0

で定義されたテンプレートをカスタムモジュールに上書きしようとしています。ファイルには、そのように定義されたproduct.info.groupedという名前のブロックがあります。だから私は、ファイル/app/code/FortyThree/GroupedConfigurableProduct/view/frontend/layout/catalog_product_view_type_grouped.xmlを作成し、それMagento 2のカスタムモジュールでテンプレートを上書きする

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd"> 
    <referenceBlock name="product.info.grouped"> 
    <action method="setTemplate"> 
     <argument name="template" xsi:type="string">FortyThree_GroupedConfigurableProduct::product/view/type/grouped.phtml</argument> 
    </action> 
    </referenceBlock> 
</layout> 

で、対応する.phtmlファイルを作成したが、それは元のテンプレートを上書きしません

<block class="Magento\GroupedProduct\Block\Product\View\Type\Grouped" name="product.info.grouped" before="product.info.addtocart" template="product/view/type/grouped.phtml"/> 

ファイル。上書きを登録するために何か必要なことはありますか?私は setup:upgradeを試して、キャッシュされた何も動作しないように見える。私は Magento_GroupedProductを私の module.xmlの配列セクションにセットして、そのロードを確実にしています。

実際には、catalog_product_view_type_grouped.xmlが読まれているようではありません。私はそこに何もしていないので問題はないようです。

答えて

0

レイアウトファイルが不適切です。

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> 
    <body> 
     <referenceBlock name="product.info.grouped"> 
      <action method="setTemplate"> 
       <argument name="template" xsi:type="string">FortyThree_GroupedConfigurableProduct::product/view/type/grouped.phtml</argument> 
      </action> 
     </referenceBlock> 
    </body> 
</page> 

はまた、あなたのモジュールにGroupedProductに依存関係を追加することを忘れないでください:

これはトリックを行う必要があります。

ブロックを適切に参照しているかどうかを確認する方法はいくつかあります。あなたは単にあなたが適切なブロックを持っていることを確認するために動作するかどうかを確認するために、単に削除を使用することができます。

関連する問題