I need to add compare and wishlist link in to the 1column.phtml file. I added this code in this page but nothing show!!!


For compare link:

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

For wishlist link:

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

How can I fix this problem?

1 Answer 1


It is because those functions do not exist on that block. The functions however just reference helpers so as long as the call to ->getProduct() is correct and returning a Mage_Catalog_Model_Product object you can do the following. Change...









Although i am still unsure as to why you are adding these to the 1column.phtml, by doing that you will need to change how you get the current product with;

$_product = Mage::registry('current_product');
if ($_product) {
    // put links in here

Magento out the box will give you add to compare / wishlist ability on listing and details pages.

  • I change these lines but when I clear the cache, the page is empty and nothing in it!
    – Elham Gdz
    Commented Sep 5, 2015 at 9:40
  • That is likely because there is no actual product available (the ->getProduct() is failing) again because no product has been set. How are you deciding what product you want to show these links for?
    – Smartie
    Commented Sep 5, 2015 at 9:43
  • I want to add these links show in all products page that customer can do compare and add product to wishlist. And also I should add these links in 1column.phtml.
    – Elham Gdz
    Commented Sep 5, 2015 at 10:23
  • I want these links work for all type of product. I just add these lines, what should I do that these links work?
    – Elham Gdz
    Commented Sep 5, 2015 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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