Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 4
best selling products/ most viewed
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

Lovely, thanks wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

Get most viewed products (most popular).

Change

$products Mage::getResourceModel('reports/product_collection')
            ->
addOrderedQty()
            
//->addAttributeToSelect('*')
            
->addAttributeToSelect(array('name''price''small_image''short_description''description')) //edit to suit tastes
            
->setStoreId($storeId)
            ->
addStoreFilter($storeId)
            ->
setOrder('ordered_qty''desc'); //best sellers on top

To

$products Mage::getResourceModel('reports/product_collection')
            
//->addAttributeToSelect('*')
            
->addAttributeToSelect(array('name''price''small_image''short_description''description'))
            ->
setStoreId($storeId)
            ->
addStoreFilter($storeId)
            ->
addViewsCount();
 
Magento Community Magento Community
Magento Community
Magento Community
 
BigWil
Jr. Member
 
Total Posts:  16
Joined:  2007-10-17
 
Bockbertil - 12 February 2009 03:19 PM

Get most viewed products (most popular).

$products Mage::getResourceModel('reports/product_collection')
            
//->addAttributeToSelect('*')
            
->addAttributeToSelect(array('name''price''small_image''short_description''description'))
            ->
setStoreId($storeId)
            ->
addStoreFilter($storeId)
            ->
addViewsCount();

This is a really cool block. Can someone help me with another? I would like a block to query 5 special price items listing them in order of the most viewed.

I could probably figure it out eventually but I am afraid it might have to query two separate models or maybe not.  I have seen examples that use the catalog product collection where special price seems to be available and then this one which uses reports product collection where the addViewCount can be added.  As you can tell I am still trying to figure this modeling out.

Big Wil

 
Magento Community Magento Community
Magento Community
Magento Community
 
weboasis
Jr. Member
 
Avatar
Total Posts:  7
Joined:  2009-04-15
Pondicherry
 

Magento Team!!!!

Please release a stable version of magento........ All the versions are still bugs .

we are only to do Cut,Copy & paste

Image Attachments
CCP.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
OzzyCzech
Jr. Member
 
Total Posts:  21
Joined:  2009-05-26
Ostrava
 

Can you please advise how to use this code. Where to place etc.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cristache
Member
 
Total Posts:  72
Joined:  2008-12-06
Bucuresti - Romania
 

Hello everyone,
I managed to show on homepage Bestselles & Most viewed products with Magento 1.3.2.2. You can find attachet the necessary files.
Here are the steps (you have to create necessary folders if they do not already exist):
1. Place *.php files here: /public_html/app/code/local/Mage/Catalog/Block/Product
2. Place *.phtml files here: /public_html/app/design/frontend/*/*/template/catalog/product
3. Create a block in your CMS for each section (Bestsellers & Most Viewed) and place this in your Content:
<p>{{block type="catalog/product_bestseller" template="catalog/product/bestseller.phtml"}} </p> - for bestsellers
<p>{{block type="catalog/product_mostviewed" template="catalog/product/mostviewed.phtml"}} </p> - for mostviewed
4. Call your blocks from CMS/Manage pages/Homepage/Custom design:
<block type="cms/block" name="bestsellers" as="banner"><action method="setBlockId"><id>bestsellers</id></action></block>
<block type="cms/block" name="mostviewed" as="banner"><action method="setBlockId"><id>mostviewed</id></action></block>

I don’t know if there is a better way, but what’s important, it worked for me this way. You can see it in action here

Cheers, Cristi

File Attachments
bestseller.phtml  (File Size: 4KB - Downloads: 2303)
Bestseller.php  (File Size: 1KB - Downloads: 2506)
Mostviewed.php  (File Size: 1KB - Downloads: 2494)
mostviewed.phtml  (File Size: 4KB - Downloads: 2080)
 
Magento Community Magento Community
Magento Community
Magento Community
 
maxmin
Member
 
Total Posts:  68
Joined:  2008-12-26
Czech Republic
 

I have a problem. When I use the flat catalog it does not display images and prices. Do you know how to fix it?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ikelewis
Jr. Member
 
Total Posts:  30
Joined:  2009-04-29
 

I am getting the following error when I use cristache’s instructions.

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

Any help would be greatly appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cristache
Member
 
Total Posts:  72
Joined:  2008-12-06
Bucuresti - Romania
 

Sorry maxmin & ikelewis,
I am not a programmer, I only wanted to put together the files and instructions I found also on this forum. The fact is this method works for me with magento 1.3.2.3.
Cheers,
Cristi

 
Magento Community Magento Community
Magento Community
Magento Community
 
wahl
Member
 
Total Posts:  36
Joined:  2009-04-10
France
 
ikelewis - 24 July 2009 01:33 PM

I am getting the following error when I use cristache’s instructions.

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

Any help would be greatly appreciated.

Don’t use the files that cristache left , use the code posted by int2k.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Cole Geissinger
Sr. Member
 
Avatar
Total Posts:  174
Joined:  2008-12-23
Northern California
 

Thanks for all the helps guys! I got mine to work, although it doesn’t seem to be grabbing pricing for bundle and grouped products…

I’m sure this has something to do with the AttributeToSelect array, but I don’t know what attribute to select for these two product types....

Can anyone tell what to do to get pricing to show for Bundle and Grouped products?
Thanks!

Here’s what my Mostviewed.php looks like

<?php
class Mage_Catalog_Block_Product_Mostviewed extends Mage_Catalog_Block_Product_Abstract
{
    
public function __construct()
    
{
        parent
::__construct();

        
$storeId    Mage::app()->getStore()->getId();

        
$products Mage::getResourceModel('reports/product_collection')
            ->
addOrderedQty()
            ->
addAttributeToSelect('*')
            ->
addAttributeToSelect(array('name''price''small_image')) //edit to suit tastes
            
->setStoreId($storeId)
            ->
addStoreFilter($storeId)
            ->
addViewsCount();


        
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
        
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);

        
$products->setPageSize(5)->setCurPage(1);

        
$this->setProductCollection($products);
    
}
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
jimfraseruk
Jr. Member
 
Total Posts:  4
Joined:  2008-08-22
 

@Cole Geissinger did you get a solution for your problem with prices not being pulled through for grouped products? I have teh same issue.

Cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
Cole Geissinger
Sr. Member
 
Avatar
Total Posts:  174
Joined:  2008-12-23
Northern California
 

@jimfraseruk - I did get this to work...I’m not sure if it was the using the same information here. This was a little while ago...let me rummage through and put some stuff up here for ya in a little bit.

- Cole

 
Magento Community Magento Community
Magento Community
Magento Community
 
Cole Geissinger
Sr. Member
 
Avatar
Total Posts:  174
Joined:  2008-12-23
Northern California
 

ahhh my brain doesn’t seem to be working today…

Sadly I have not found the solution to the pricing problem
If anyone has any information on a fix please supply! rasberry

- Cole

 
Magento Community Magento Community
Magento Community
Magento Community
 
afmaury
Sr. Member
 
Total Posts:  100
Joined:  2008-01-05
 

How can I get this to display in the left column on every page?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 4