Bestseller product code in magento

<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<?php $_columnCount = 4; ?>
<div class="best-seller-title">
    <h2><?php echo $this->__('Best Products') ?></h2>
</div>
<?php $_collectionSize = $_products->getItems() ?>

<?php $i=0; foreach ($_collectionSize as $_product): ?>
  
        <ul class="best-seller">
  <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">  
      <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>"> <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(136,136); ?>" width="136" height="136" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>
      <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
      <div class="a-center">
       
      
       
        <div class="price">
        <?php echo $this->getPriceHtml($_product, true) ?>
        </div>
        <?php if($_product->isSaleable()): ?>
       <button class="button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
    
       <div class="clear"></div>
        <?php else: ?>
<p class="availability"><span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span></p>
<div class="clear"></div>
        <?php endif; ?>
        <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<h1>

        </h1>
        <?php if($_product->getevent_date()) {echo $_product->getevent_date();} ?>
      </div>
    </div>
   
  <?php  endforeach; ?>
</li>

</ul>

<script type="text/javascript">decorateGeneric($$('ul.best-seller'), ['odd','even','first','last'])</script>
<?php endif; ?>

Comments