1

I want to override the summary.phtml template (vendor/magento/module-review/view/frontend/templates/helper/summary.phtml) with a custom module.

The template is overridden in the catalog_product_view.xml layout file with this code:

<referenceContainer name="content">
  <referenceBlock name="product.info.review" template="Vendor_Catalog::review/helper/summary.phtml"/>
</referenceContainer>

My template is well displayed but the data of the block is not accessible. I cannot use the default block methods (getReviewsUrl, etc).

I have tested this method but my custom template is not loaded:

<?xml version="1.0"?>
<page layout="1column" 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.review" >
        <arguments>
            <argument name="template" xsi:type="string">Vendor_Catalog::review/helper/summary.phtml</argument>
        </arguments>
    </referenceBlock>
    </body>
</page>

Do I have to override the block? Is there another way?

1 Answer 1

0

There are no need to add call block under reference contaniater name

 <referenceBlock name="product.info.review" template="Vendor_Catalog::review/helper/summary.phtml"/>

under

<referenceContainer name="content"></referenceContainer>

Just do this:

<?xml version="1.0"?>
<page layout="1column" 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.review" >
        <arguments>
            <argument name="template" xsi:type="string">Vendor_Catalog::review/helper/summary.phtml</argument>
        </arguments>
    </referenceBlock>
    </body>
</page>
2
  • I have already tried this method but my custom template is not loaded.
    – Mathieu
    Jul 26, 2017 at 5:15
  • I also tried with the setTemplate xml method, same problem.
    – Mathieu
    Jul 26, 2017 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.