Magento - Displaying Add to Compare button on New Products block

Magento - Displaying Add to Compare button on New Products block

October 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Displaying Add to Compare button on New Products block

Magento: Displaying Add to Compare Button on New Products Block

Hello developers! Today we’ll be diving into an issue faced by Kevin regarding displaying the “Add to Compare” button on the “New Products” block in Magento 1.9.

Current Setup and Issue

Kevin has configured the home page of his Magento store to display new products using the catalog/product_new block type. Here’s a breakdown of his current setup:

XML Configuration

<reference name="content">
    <block type="catalog/product_new" name="home.catalog.product.new"
           alias="product_new" template="catalog/product/new.phtml"
           after="cms_page">
        ...
    </block>
</reference>

The new.phtml file in his custom theme folder contains the necessary code to display “Add to Compare” links for each new product. However, despite this configuration, Kevin is unable to see these buttons on the “New Products” block.

Analyzing the New PHTML File

Let’s take a closer look at the relevant portion of the new.phtml file:

...
<ul class="add-to-links">
    <?php if ($this->helper('wishlist')->isAllow()) : ?>
        <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>"
               class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
    <?php endif; ?>

    <?php if ($_compareUrl = $this->getAddToCompareUrl($_product)): ?>
        <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>"
                                              class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
    <?php endif; ?>
</ul>
...

The “Add to Wishlist” and “Add to Compare” links are being generated using the getAddToWishlistUrl and getAddToCompareUrl methods, respectively. However, Kevin only sees an image of each product and its price on the block.

Identifying the Problem

Upon reviewing the code, it seems that the issue might be related to the catalog/product_new block type not supporting these methods out-of-the-box. To verify this, we need to locate the class file corresponding to the catalog/product_new block type and check its functionality.

Finding the Block Class File

The catalog/product_new block likely extends or uses the Mage_Catalog_Block_Product_Abstract class as a base. You can find this class in your Magento installation at:

app/code/core/Mage/Catalog/Block/Product/Abstract.php

Checking Method Availability

Open the Abstract.php file and search for the presence of methods like getAddToCompareUrl. If these methods are not defined or overridden, then the block type does not support them.

Potential Solutions

  1. Override the Block Class: Create a new block class that extends catalog/product_new and override the necessary methods to include functionality for “Add to Compare” buttons.

  2. Use Another Block Type: If overriding is not feasible or desired, consider using a different block type that supports the required functionality, such as catalog/product_list.

  3. Manually Include Buttons: Modify the existing phtml template to manually include the “Add to Compare” button for each product without relying on the block’s built-in methods.

Conclusion

In conclusion, Kevin is facing this issue due to a potential limitation in the functionality of the catalog/product_new block type. To resolve it, he has a few options:

  • Override the block class to include the required functionality.
  • Switch to another block type that supports “Add to Compare” buttons.
  • Manually include the buttons in the phtml template.

I recommend reaching out to Magento’s official documentation or forums for more detailed guidance on overriding block classes. Additionally, consider exploring third-party extensions that might provide better support for this feature.

Remember, always test changes thoroughly in a development environment before applying them to your live store. Happy coding!

Back to Laravel Company for more Magento tips and tricks!

Magento 1 Catalog Themes Configuration

Our network