1

I have created a custom theme but the review tab is not showing on product page. If I change my custom theme for default luma theme than the review tab starts displaying on product page.

Is there someone who can guide me what am I doing wrong?

7

Add review tab in custom theme's catalog_product_view.xml in product.info.details block

app/design/frontend/{Vendor}/{theme}/Magento_Catalog/layout/catalog_product_view.xml

<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>

Final catalog_product_view look like this:

<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media">
...
...

<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>
  • 1
    Hi Prince, thanks a lot it works but after submitting review it store and not display success message on product page and when I click on other page or link it display success message on that page. – Rahul Jat Jan 31 '18 at 7:35
  • Plz check this queue: magento.stackexchange.com/questions/76515/… OR ask a new question about success message because it is not related to review tab. – Prince Patel Jan 31 '18 at 8:57
3

Review block will not work in custom Magento 2 theme.

To show Review tab on the product page you should have to add JsLayout at the following location.

app/design/frontend/{Vendor}/{theme}/Magento_Review/layout/catalog_product_view.xml

Add the following code in above located file.

<referenceBlock name="product.review.form">
 <arguments>
    <argument name="jsLayout" xsi:type="array">
        <item name="components" xsi:type="array">
            <item name="review-form" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Review/js/view/review</item>
            </item>
        </item>
    </argument>
</arguments>
</referenceBlock>
  • Working fine for me !! – Dhara Parmar Jul 5 '18 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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