Magento - showing review links & add-to-compare links on custom pages

Magento - showing review links & add-to-compare links on custom pages

July 28, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - showing review links & add-to-compare links on custom pages

Magento: Displaying Review Links and Add-to-Compare Links on Custom Pages

In Magento, displaying product links such as reviews and “Add to Compare” buttons on custom pages can be a common challenge faced by developers. This article will guide you through resolving this issue when working with custom CMS pages or other non-standard layouts.

You’ve created a custom page for your Magento homepage, hardcoding the content directly in the default CMS page (cmspage_id = 1). You’re successfully displaying a list of products using the same template code as the default catalog product listing. However, the “Review” and “Add to Compare” links are missing from this custom page.

The relevant PHP snippets:

<?php $_compareUrl=$this->getAddToCompareUrl($_product); ?>

and

<?php echo $this->getReviewsUrl() ?>

appear to have no effect outside the default category listing page. You’re using a product collection loaded with Mage::getResourceModel('reports/product_collection'), but these links still won’t display.

Understanding the Issue

The problem lies in how Magento handles page-specific product view functionality. By default, the “Add to Compare” and “Review” link generation is tightly coupled with the category listing layout (catalog_category_view.xml). When you’re working with a custom page, this coupling causes these links to be missing.

To resolve this issue, we need to manually initiate the product view functionality on our custom page. This requires extending the default template file and including the necessary blocks for link generation.

Step 1: Extend the Default Template File

First, create a new file in your theme directory:

app/design/frontend/[your_brand]/[theme_name]/template/catalog/product/list.phtml

Copy all the content from app/design/frontend/base/default/template/catalog/product/list.phtml, and paste it into this new file.

Step 2: Include the Necessary Blocks

Add the following lines right after the initial PHP opening tag in your extended template file:

<?php echo $this->getLayout()->createBlock('catalog/product_list')->setTemplate('catalog/product/list.phtml'); ?>

This block creation will ensure that all the necessary link generation logic is applied to your product collection.

Step 3: Update Your Product Listing

In your custom page where you’re displaying products, replace or update the existing product listing code with this extended template file:

<?php echo $this->getLayout()->createBlock('catalog/product_list')->setTemplate('catalog/product/list.phtml'); ?>

Ensure that you have the correct path to the new template file.

Why This Solution Works

By extending the default listing template and including the necessary blocks, we’re essentially telling Magento to apply its standard product view logic to our custom page. This includes generating both the “Add to Compare” and “Review” links for each product in the collection.

The extended template ensures that all the relevant XML layouts (catalog_category_view.xml) are processed correctly when rendering your custom page, thereby including the required link generation.

Conclusion

Displaying review and add-to-compare links on custom Magento pages requires a manual extension of the default product listing template. By following this approach, you can successfully apply Magento’s standard product view functionality to any custom layout or CMS page.

Remember, when working with Magento, understanding how the platform couples different functionalities together is key to resolving most display issues like these. Always look for opportunities to extend existing templates and blocks rather than reinventing the wheel.

Happy coding! For more insights into Magento development best practices, check out our other blog posts at Laravel Company.

Catalog Themes Errors

Our network