2

I have created a custom template for the product page based on the attribute value.

in my template i used below code to display the review section.

<?php  echo $block->getLayout()->createBlock("Magento\Catalog\Block\Product\View")->setTemplate("Magento_Catalog::product/view/review.phtml")->toHtml(); ?>

with this code, i can see the link 'Be the first to review the product'.

But after clicking the link, the review form tab is not expanding. Can anyone help me on this please?

sometimes in console i get this error,

Uncaught Error: no such method 'activate' for tabs widget instance

Please check this n share your ideas.

Thanks in Advance!!

8
  • you tried this code --- magento.stackexchange.com/a/195130/85907 Commented Jun 5, 2020 at 19:31
  • Yes @mohit, but no luck Commented Jun 6, 2020 at 4:11
  • After code you run all command with clear var/cache and var/view_process??? Commented Jun 6, 2020 at 4:16
  • Hi, why didn't you moved/edited the already existing review template(which contains the "Be the first to review the product/rating stars") ? Commented Jun 6, 2020 at 12:41
  • I have a requirement to load separate product page based the product attribute, loaded the separate template for it. Commented Jun 6, 2020 at 14:45

1 Answer 1

0

Add this code to layout XML of your extension :

<referenceContainer name="content">
        <block class="Magento\Cookie\Block\RequireCookie" name="require-cookie" template="Magento_Cookie::require_cookie.phtml">
            <arguments>
                <argument name="triggers" xsi:type="array">
                    <item name="submitReviewButton" xsi:type="string">.review .action.submit</item>
                </argument>
            </arguments>
        </block>
            <block class="VENDOR\EXTENSION\Block\Order\Products" name="review_products" template="VENDOR_EXTENSION::proreview.phtml">
                <block class="Magento\Review\Block\Product\Review" name="reviews.tab" as="reviews" template="Magento_Review::review.phtml" group="detailed_info">
                    <block class="Magento\Review\Block\Form" name="product.review.form" as="review_form">
                        <container name="product.review.form.fields.before" as="form_fields_before" label="Review Form Fields Before"/>
                    </block>
                </block>
            </block>
</referenceContainer>

Now add your review.phtml code in to your phtml so it will work.

Happy coding.

1
  • hi @Mayur, can you explain briefly. its not working in default detail page also Commented Jul 6, 2020 at 9:14

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.