Removing Magento Customer Reviews from Product View Page
As a developer working on a custom Magento module for customer reviews, you may find that the built-in review functionality needs to be removed from the product view page. This guide will walk you through the process of deleting the Magento customer review block from the catalog_product_view.xml layout file.
Understanding the Default Magento Layout
By default, Magento includes a customer reviews block in the catalog_product_view.xml layout file located in the app/design/frontend/[your_package]/[your_theme]/layout/ directory. The relevant section of code looks like this:
<referenceContainer name="content">
<block class="Magento\Review\Block\Product\View" name="review_tabs"/>
</referenceContainer>
Here, the review_tabs block is responsible for displaying customer reviews on the product view page.
Removing the Customer Reviews Block
To remove this block from the layout file, open the catalog_product_view.xml file and comment out or delete the line containing the block definition:
<!--<referenceContainer name="content">
<block class="Magento\Review\Block\Product\View" name="review_tabs"/>
</referenceContainer>-->
Alternatively, you can use the following more efficient approach using layout handles:
-
Open or create a new XML file in the
app/code/[Vendor]/[Module]/view/frontend/layoutdirectory. -
Add the following content to this new file:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/layout.xsd">
<layout>
<update handle="catalog_product_view"/>
<referenceBlock name="review_tabs" remove="true"/>
</layout>
</config>
In this code, we use the remove attribute with a value of true to instruct Magento to delete the review_tabs block from the layout.
Clearing Cache and Checking Results
After making these changes, be sure to clear your cache for the updates to take effect. You can do this manually in the Magento admin panel under System > Cache Management or by running the following command in your terminal:
php bin/magento cache:clean
Once the cache is cleared, navigate to a product page on your frontend. The customer reviews section should no longer be visible.
Conclusion
Removing the built-in Magento customer review block from the product view page allows you to integrate your custom module’s functionality without interference. Remember that layout updates require clearing the cache for changes to appear on the frontend.
If you’re looking to build a custom Magento module or need more advanced development assistance, consider reaching out to Laravel Company, where our team of experienced developers can help you achieve your e-commerce goals with professionalism and expertise.