Customizing the Reviews Page Layout in Magento
As an experienced developer at Laravel Company, I frequently receive queries about customizing the layout of various pages in Magento, including the reviews page. Let’s dive into how to specifically remove the “Related Products” and “You may also be interested in” blocks from the reviews page without affecting the primary product page.
Understanding the Current Setup
The issue arises because these two blocks are currently being rendered on both the main product page and the reviews page using a single template file - frontend/default/xxxx/template/catalog/product/view.phtml. This is a common design pattern in Magento, but it can lead to difficulties when you want to customize individual pages.
Approach: Override the Template
To resolve this, we’ll need to override the default template for the reviews page while keeping the original template intact for other pages. Here’s how:
- Create a new file: In your custom theme directory (e.g.,
app/design/frontend/yourpackage/yoursubpackage), navigate to the following path and create a new folder named “catalog/product”:
- yourpackage
- yoursubpackage
- template
- catalog
- product
-
Copy and paste: Copy the existing
view.phtmlfile from the default theme (usually inapp/design/frontend/base/default) to this new folder. -
Modify the copy: Open your copied
view.phtmlfile in a text editor or IDE. Search for the following lines:
<block type="catalog/product_list_related" name="catalog.product.list.related" template="catalog/product/list.phtml"/>
<block type="reports/product_viewed" name="catalog.reports.viewed.products" as="viewed_products" template="report/viewed.phtml"/>
These lines are responsible for rendering the “Related Products” and “You may also be interested in” blocks, respectively.
- Comment out or remove: To remove a block, simply comment it out or delete the corresponding line:
<!-- <block type="catalog/product_list_related" name="catalog.product.list.related" template="catalog/product/list.phtml"/> -->
<block type="reports/product_viewed" name="catalog.reports.viewed.products" as="viewed_products" template="report/viewed.phtml"/>
- Deploy static content: After saving your changes, run the following command in your terminal to deploy the updated static files:
php bin/magento setup:static-content:deploy -f
Verifying the Changes
Once you’ve completed these steps and refreshed the reviews page, you should see that the “Related Products” block has been removed without affecting its presence on other pages like the main product detail page.
This approach demonstrates a key principle of Magento theme customization: always override rather than modifying core files directly. Overriding allows for easier updates and prevents potential conflicts with future Magento patch releases.
Remember to replace yourpackage and yoursubpackage in the example paths with your actual package names.
For more detailed information on Magento customization best practices, I recommend checking out our comprehensive guide at Laravel Company’s Magento Development Blog.
Conclusion
In this post, we’ve explored how to selectively remove blocks from the reviews page in Magento while keeping them intact on other pages like the main product detail view. By understanding and applying the concept of template overriding, you can maintain a clean and organized codebase that is easy to manage.
If you’re looking for professional assistance with your Magento development needs or have any further questions about Magento customization, don’t hesitate to contact us at Laravel Company. Our expert team is always ready to help you achieve the perfect e-commerce solution.