cancel
Showing results for 
Search instead for 
Did you mean: 

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

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

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

I have to display best selling products list, just confused what is the best practice.

 

Create Module & CMS Page

 

Getting best selling values from database using products id display product image, name, price, add to cart. For doing this which practice is best

 

1) Create module :

Create module like following practice,
https://www.pierrefay.com/magento-training/create-a-controller-tutorial.html

 

2) CMS Page :

Create .phtml file inside the theme/template/page/my_code/best_selling_list.phtml and getting template value in cms page using

 

{{block type="core/template" template="page/my_code/best_selling_list.phtml"}}

 

Both are dedicated new URL, What is the best practice?

15 REPLIES 15

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

@Aveeva instead of creatign a new module you can use this free extension to show best selling products.

 

Please have a look.

https://marketplace.magento.com/magehit-magehit-bestsellerproducts.html

 

Thanks

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

@rahul Gupta  How to display best seller products by parent category wise. In my website there are 10 category, parent category wise how can i display my best seller products.

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

@Aveeva please check the below link

 

https://mercytapscott.com/display-bestsellers-for-specific-magento-categories/

 

In this you can replace this if($categoryId=$this->getData('category_id')) with f($categoryId=Mage::registry('current_category')) so that you can get the  products of only current category.

 

Found useful,please Accept it as Solution.

 

Thanks

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

@rahulGupta  

 

I am folowing https://mercytapscott.com/display-bestsellers-for-specific-magento-categories/

CMS page error.

 

Fatal error: Call to a member function productAttribute() on null in /home/abc/public_html/app/design/frontend/default/theme/template/catalog/product/bestseller.phtml on line 6

 

<?php if (($_products = $this->getProductCollection())): ?>
<ul class="top-products">
  <?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; ?>

may i know what is error?

 

Note : My menu hide in cms page.

 

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

@rahul Gupta  Any help thanks.

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

@Aveeva There is no function with the name productAttribute().

 

Please search this function in your template file and remove it and if you want to use then create a function with this name in its block file.

 

Thanks

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

@rahul Gupta  After adding <?php $_helper = Mage::helper('catalog/output'); ?>  the issue solved.

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

@rahulGupta    The values return like one by one LIKE,

 

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

how can i separate like,

 

A     B     C     D

E     F     G     H

I      J      K     L

M    N     O     P

Q    R     S     T

 

Code:

 

<?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 echo $this->getPriceHtml($_product, true) ?>

    </li>
  <?php endforeach; ?>
</ul>
<?php endif; ?>

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

@Aveeva you can use the increment opeartor.

 

Also instead of ul and li just use div.

 

As you are doing this in foreach, so take a variable "$i" and increment it every time and by the time its value is 4 use </br> tag for next line.


Thanks