I have the bestsellers on my homepage. However, If I click on the product image it does nothing. It only redirects If I click on the product title under the image.

I want it to redirect if I click in the image also not only the product title. I want it to be same as the catalog page if I click on the image it will redirect.

$_helper = $this->helper('catalog/output');
$_productCollection = Mage::getModel('catalog/product')
->addAttributeToSort('created_at', 'DESC')
->addAttributeToFilter('status', 1) 
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('best_seller', 1)
$count = 1;
foreach ($_productCollection as $_product) {
<div class="col-12 col-sm-4 col-md-3 col-lg-3">
    <div class="populer-h-bx wow fadeInUp" data-wow-delay="0.<?php echo 
 $count*6; ?>s" data-wow-duration="1s">
        <?php $_imgSize = 250; ?>
        <img id="product-collection-image-<?php echo $_product->getId(); ?>"
             src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>"
             alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>"
        <div class="h-populer-info">
            <h4><a href="<?php echo $_product->getProductUrl(); ?>"><?php echo $_product->getName() ?></a></h4>
            <div class="price-populer">
                $product = Mage::getModel('catalog/product')->load($_product->getId());
  $productBlock = $this->getLayout()->createBlock('catalog/product_price');
  echo $productBlock->getPriceHtml($product);

            <h6><?php echo $_product->getAttributeText('manufacturer');?></h6>
            <div class="actions hover-social">
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <li><a title="<?php echo $this->__('Add to Wishlist') ?>"
                               href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"
                                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>images/link-heart.png"></a>
                    <?php endif; ?>
                    <li><a title="<?php echo $this->__('View Product') ?>"
                           href="<?php echo $_product->getProductUrl(); ?>"><img
                                    src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>images/link-eye.png"></a>
                    <?php if ($_product->isSaleable() && !$_product->canConfigure()): ?>
                            <a type="button" title="<?php echo $this->__('Add to Cart') ?>" class="btn-cart"
                               onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product' => $_product->getId(), 'qty' => 1, 'form_key' => Mage::getSingleton('core/session')->getFormKey())) ?>')">
                                                src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>images/link-shopping.png"></span></span></a>
                    <?php elseif ($_product->isSaleable()): ?>
                            <a title="<?php echo $this->__('View Details') ?>" class="button"
                               href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->__('View Details') ?></a>
                    <?php else: ?>
                            <p class="availability out-of-stock">
                                <span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>


$count++;} ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.