cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9 - what is the best practice to Display Top selling products list?

Re: Magento 1.9 - what is the best practice to Display Top selling products list?

@Aveeva try below code.

 

<?php $_helper = Mage::helper('catalog/output'); ?> 
<?php if (($_products = $this->getProductCollection())):
          $i = 0;
 ?>
<div class="top-products" id = "limheight">
  <?php foreach ($_products->getItems() as $_product): ?>   
    <div>
      <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
      
                <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
                <?php echo $this->getPriceHtml($_product, true) ?>
		<? $i++; ?>

    </div>
<?php if($i>4):
   $i = 0;
   echo "</br>";
endif;
 ?>
  <?php endforeach; ?>
</div>
<?php endif; ?>

Thanks

Re: Magento 1.9 - what is the best practice to Display Top selling products list?

@rahul Gupta  Still products shown one by one.

 

code :

 

<?php $_helper = Mage::helper('catalog/output'); ?> 
<?php if (($_products = $this->getProductCollection())):
          $i = 0;
 ?>
<div class="top-products" id = "limheight">
  <?php foreach ($_products->getItems() as $_product): ?>   
    <div>
      <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
      
                <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
                <?php echo $this->getPriceHtml($_product, true) ?>
        <? $i++; ?>

    </div>
<?php if($i>4):
   $i = 0;
   echo "</br>";
endif;
 ?>
  <?php endforeach; ?>
</div>
<?php endif; ?>

Re: Magento 1.9 - what is the best practice to Display Top selling products list?

@Aveeva can you share the public url or screenshot for the same.

 

Thanks

Re: Magento 1.9 - what is the best practice to Display Top selling products list?

Code :

 

<html>
<head>
    <style type="text/css">
    #limheight 
    { 
        display:grid;
        grid-template-columns: repeat(5, 1fr);
        grid-row-gap: 40px;
        text-align: center; 
    }   
    </style>
</head>
</html>

<?php $_helper = Mage::helper('catalog/output'); ?> 
<?php if (($_products = $this->getProductCollection())): ?>
<ul class="top-products" id = "limheight">
  <?php foreach ($_products->getItems() as $_product): ?>   
    <li>
      <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
      
                <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>

             <!--    <?php if($_product->getRatingSummary()): ?>
                <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                <?php endif; ?> -->
                <?php echo $this->getPriceHtml($_product, true) ?>
<!--                 <div class="actions">
                    <?php if($_product->isSaleable()): ?>
                        <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                    <ul class="add-to-links">
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                            <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_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>
                </div> -->
    </li>
  <?php endforeach; ?>
</ul>
<?php endif; ?>

System view :

 

https://imgur.com/FdPeHac

 

mobile view :

 

https://imgur.com/nvtLNKo

 

How to view mobile view like 

 

 

A    B

C   D

E   F

G   H

 

(or)

 

scroll 2 by 2.

 

 

Re: Magento 1.9 - what is the best practice to Display Top selling products list?

@Aveeva You can use the css for mobile phones.

 

You can select the media width and show only 2 products instead of 5 in phones.

 

If your issue is solved please "Accept as Solution".

 

Thanks

Re: Magento 1.9 - what is the best practice to Display Top selling products list?

@rahul Gupta  What is the value i need to declare?

 

 @media only screen and (max-width: 767px)
    #limheight
    {
        
    }