0

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.

<?php
$_helper = $this->helper('catalog/output');
$_productCollection = Mage::getModel('catalog/product')
->getCollection()
->setPageSize(8)
->addAttributeToSort('created_at', 'DESC')
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1) 
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('best_seller', 1)
->load();
$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) ?>"
             class="img-fluid"/>
        <div class="h-populer-info">
            <h4><a href="<?php echo $_product->getProductUrl(); ?>"><?php echo $_product->getName() ?></a></h4>
            <div class="price-populer">
                <?php 
                $product = Mage::getModel('catalog/product')->load($_product->getId());
  $productBlock = $this->getLayout()->createBlock('catalog/product_price');
  echo $productBlock->getPriceHtml($product);

                ?>
            </div>
            <h6><?php echo $_product->getAttributeText('manufacturer');?></h6>
            <div class="actions hover-social">
                <ul>
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <li><a title="<?php echo $this->__('Add to Wishlist') ?>"
                               href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"
                               class="link-wishlist">
                                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>images/link-heart.png"></a>
                        </li>
                    <?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>
                    </li>
                    <?php if ($_product->isSaleable() && !$_product->canConfigure()): ?>
                        <li>
                            <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())) ?>')">
                                <span><span><img
                                                src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>images/link-shopping.png"></span></span></a>
                        </li>
                    <?php elseif ($_product->isSaleable()): ?>
                        <li>
                            <a title="<?php echo $this->__('View Details') ?>" class="button"
                               href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->__('View Details') ?></a>
                        </li>
                    <?php else: ?>
                        <li>
                            <p class="availability out-of-stock">
                                <span><?php echo $this->__('Out of stock') ?></span></p>
                        </li>
                    <?php endif; ?>


                </ul>
            </div>
        </div>
    </div>
</div>

<?php
$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.