Magento Forum

best selling products/ most viewed
 
fab4u67
Jr. Member
 
Total Posts:  25
Joined:  2008-01-04
 

Thank you everybody for these nice pieces of code.

But, I wonder how to display block with best sellers products filtered by categories, in order to show best sellers products according to category or sub-category customer navigate

 
Magento Community Magento Community
Magento Community
Magento Community
 
webscot
Sr. Member
 
Total Posts:  192
Joined:  2009-05-12
 

Any idea why when using the Mostviewed.php as presented by Cole in

http://www.magentocommerce.com/boards/viewthread/14764/P15/#t170622
I would receive the following error?

Parse error: syntax error, unexpected T_STRING in /chroot/home.../app/code/local/Mage/Catalog/Block/Product/Mostviewed.php on line 11

I have not been able to get either the mostviewed or the bestseller to work in the home page.

Using 1.3.2.2

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Red Mouse Computers
Sr. Member
 
Total Posts:  123
Joined:  2009-10-04
 

anyone figure out how to do this for 1.4.0.1?

 
Magento Community Magento Community
Magento Community
Magento Community
 
bolasevich
Sr. Member
 
Avatar
Total Posts:  235
Joined:  2008-03-04
Newington, CT USA
 

here’s a possible solution for 1.4 and up. Magento has moved to using widgets to do things like this.

http://www.magewidgets.com/magento-widgets/top-sellers-bestsellers-widget.html

 
Magento Community Magento Community
Magento Community
Magento Community
 
jazkat
Sr. Member
 
Total Posts:  154
Joined:  2009-07-09
 

I used cristache’s code and also got errors like ikelewis
Fatal error: Call to undefined function mainblock() in /home6/theserap/public_html/store/app/design/frontend/default/magesupport/template/catalog/product/mostviewed.phtml on line 2

What solved the problem in both mostviewed and bestseller phtml files was deleting some code that probably only cristache needed.
So if you remove the following lines it should work!:

<?php mainBlock('top'?>
<?php title('top'?>
<?php title('bottom'?>
<?php contentBlock('top'?>
<?php contentBlock('bottom'?>
<?php mainBlock('bottom'?>

Thanks for all good work everyone!

 
Magento Community Magento Community
Magento Community
Magento Community
 
kunjesh
Jr. Member
 
Total Posts:  17
Joined:  2010-03-08
 

Hi all,

I want to display \"Best Seller in a week\” on my home page, Please help me out.

$products Mage::getResourceModel(\'reports/product_collection\')
            ->
addOrderedQty()
            ->
addAttributeToSelect(\'*\')
            ->
setStoreId($storeId)
            ->
addStoreFilter($storeId)
            ->
setOrder(\'ordered_qty\'\'desc\');

what should i add another parameter so i can reach at my destination.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rodrigo423
Member
 
Total Posts:  32
Joined:  2009-03-18
 

I used Cristi’s code. In content view, the stuff comes up. But, for some reason, it does not show up as a block. I can\’t figure this out.
Does it relate to the theme I use??

<block type="cms/block" name="mostviewed" as="banner"><action method="setBlockId"><id>mostviewed</id></action></block>

I use 1.4.0.1
Any suggestions are appreciated. Thanks

Rod

 
Magento Community Magento Community
Magento Community
Magento Community
 
nabler
Sr. Member
 
Total Posts:  80
Joined:  2010-07-27
 
rodrigo423 - 31 May 2010 07:14 PM

I used Cristi’s code. In content view, the stuff comes up. But, for some reason, it does not show up as a block. I can\’t figure this out.
Does it relate to the theme I use??

<block type="cms/block" name="mostviewed" as="banner"><action method="setBlockId"><id>mostviewed</id></action></block>


I use 1.4.0.1
Any suggestions are appreciated. Thanks

Rod

that not for your magento version....

 
Magento Community Magento Community
Magento Community
Magento Community
 
wallysson
Jr. Member
 
Total Posts:  3
Joined:  2010-07-26
 

English Version Best Seller And most Viewed
Magento Version: 1.4.1.1
Status: Working website RH Super (Just using Bestseller)

------------------------------------------------------------------------------------------------

Hey guys, just try to do wha jazkatt sayd…
Step by step to make this work:

1. Download all the updated files files(i have updated them):
If you would like to download the original files posted by cristache, the link is:
http://www.magentocommerce.com/boards/viewthread/14764/P15/

2. When you download all the files, Edit these lines:
(if you have downloaded the updated files, jump to the third step)

<?php mainBlock('top'?>
<?php title('top'?>
<?php title('bottom'?>
<?php contentBlock('top'?>
<?php contentBlock('bottom'?>
<?php mainBlock('bottom'?>

Just open each PHTML file and edit them(Just have 2 files)

3. When you have finished, put all the files in the correct folder.
Place *.php files here: /public_html/app/code/core/Mage/Catalog/Block/Product
Place *.phtml files here: /public_html/app/design/frontend/*/*/template/catalog/product
(The * is your template folder)

4. Now, you will create static blocs at the main menu of your admin system. Acess these menu:
CMS -> static blocs -> new block

In the page to create the new block, fill the form with the required information.
The unique information you need to put, and can’t be diferent is the form content and it will be filled with this value:
{{block type="catalog/product_bestseller" template="catalog/product/bestseller.phtml"}}
fill the name as Bestseller

Do the same think whith the most viewed, create an static block and fill the content value with:
{{block type="catalog/product_mostviewed" template="catalog/product/mostviewed.phtml"}}
fill the name as Mostviewed

5. The next step is to put the block working on the fist page
Acess the menu system: CMS -> pages ->home -> content

Desabilite the editor text, clicking at “Show / Hide Editor”
After clicking on it, click on the button: “Insert Widget”

An new window will open, choose CMS static block at the dropdown
And hit the button: Select

An grid with all static blocks will be showed, choose your static block and hit “Insert Widget” at the top of the window,
An variable of the system like this should appear at the text form:

{{widget type="cms/widget_block" template="cms/widget/static_block/default.phtml" block_id="6"}}

6. Now, styling… Edit pages HTML from PHTML the way you want. Put styles, divs and everything you need.
The variable {{widget type="cms/widget_block" template="cms/widget/static_block/default.phtml" block_id="6"}} can pe puted inside divs at the content home page.

If you do all the steps, should be working nice!
------------------------------------------------------------------------------------------------

Any help, ask me at:
Se alguém precisar de uma tradução galera…
Posso estar traduzindo também…

Me enviem um email caso seja necessário!
Good luck Guys!

File Attachments
Bestseller.php  (File Size: 1KB - Downloads: 880)
Mostviewed.php  (File Size: 1KB - Downloads: 618)
bestseller.phtml  (File Size: 4KB - Downloads: 702)
mostviewed.phtml  (File Size: 4KB - Downloads: 558)
 
Magento Community Magento Community
Magento Community
Magento Community
 
divinemonkey
Member
 
Avatar
Total Posts:  49
Joined:  2009-11-11
 

Guys, does this still work ok with caching enabled?

I have a list of best-selling items in my footer, which is embedded directly in my footer.phtml using the following code (which is almost identical to the code in the files above):

$_productCollection Mage::getResourceModel('reports/product_collection')
->
addAttributeToSelect('name')
->
addAttributeToFilter('visibility'$visibility)
->
addOrderedQty()
->
setOrder('ordered_qty''desc')
$_productCollection->load();}

However, I just realised that when the cache is enabled, the list doesn’t get updated until I refresh the cache. Is there any way around that?

 
Magento Community Magento Community
Magento Community
Magento Community
 
sniffer2007
Jr. Member
 
Total Posts:  20
Joined:  2007-11-30
Russia
 

If you want get most viewed products for last 24 hours:

$today time();
$yesterday $today - (60*60*24*1);

$from date("Y-m-d"$yesterday);
$to date("Y-m-d"$today);

Now, add $from and $to to addViewsCount() function. Like this:

->addViewsCount($from$to)

Now, you get most viewed products for last 24 hours.

Thanks for Mukesh

 
Magento Community Magento Community
Magento Community
Magento Community
 
dartmaul
Member
 
Avatar
Total Posts:  53
Joined:  2009-09-06
 

I am trying to filter out Out of Stock products by using:

Mage::getSingleton(’cataloginventory/stock’)->addInStockFilterToCollection($products);

in mostviewed.php

However this doesn’t work....has anyone successfully got this to work?

Many thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
dartmaul
Member
 
Avatar
Total Posts:  53
Joined:  2009-09-06
 

Any ideas anyone?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Joy Thomas
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2011-01-19
Gurgaon
 

Get best seller products

* Best selling product by shailesh thapa */
$storeId = Mage::app()->getStore()->getId();
$_productCollection = Mage::getResourceModel(’reports/product_collection’)
->addAttributeToSelect(’*’)
->setStoreId($storeId)
->addStoreFilter($storeId)
->addOrderedQty();

 
Magento Community Magento Community
Magento Community
Magento Community
 
Magazento
Sr. Member
 
Avatar
Total Posts:  155
Joined:  2010-01-08
Russia,Volgograd
 

or use Easy Topsellers extension by Magazento.com
bestsellers

- Bestsellers time in days on Homepage at Category Page
- Bestsellers count on Homepage or at Category Page
- You could select specific category ID for bestsellers on homepage or show all site bestseller
- On categories extension will show product from current category ( on phones category = it will show phone bestseller)
- Enable/Disable actions for bestsellers (Add to cart)
- Enable/Disable price showing
- Easily Enable/Disable for showing out of stock products

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top