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

How to extend bestsellers and other reports to show more than 5 entries? 
 
stewdawg35
Member
 
Total Posts:  41
Joined:  2007-12-10
 

I am hoping this is an easy fix but it seems odd to limit the bestsellers report to just the top 5 products. Our store has hundreds of items and we’d like to know how they all stack up and compare.

Does anyone know of a way to modify or of a 3rd party app that will give us a full listing of how many time each product has been sold?

i would like to think that somewhere there is a file where we can change the output number to whatever we want similar to how we modified the new products page to display more than 5. The data is there we just need to find a way to display it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tobillo
Member
 
Avatar
Total Posts:  46
Joined:  2008-04-07
Germany
 

same here! i want to know this too…

 
Magento Community Magento Community
Magento Community
Magento Community
 
feedcorn
Jr. Member
 
Total Posts:  2
Joined:  2009-06-12
 

Agreed! I’ve been searching for this for a little while…

 
Magento Community Magento Community
Magento Community
Magento Community
 
ConvenientGadgets
Sr. Member
 
Total Posts:  78
Joined:  2008-12-29
 

K, trying this post again.

I couldn’t figure out how to change the report, at least relatively easily. So this query will provide a count of products and number sold for whatever date range you put in the query. I’ve grouped by day.

select name, date(created_at) as orderdate, sum(qty_ordered) from sales_flat_order_item where product_type <> ‘configurable’ and created_at > ‘2009-11-01 05:00:00’ and created_at < ‘2009-12-04 00:05:00’ group by orderdate, name order by name, orderdate limit 0, 500

Example output:

ProductA, 11/15/09, 3
ProductA, 11/17/09, 5
ProductA, 11/18/09, 4
ProductB, 11/15/09, 1
ProductB, 11/16/09, 6
ProductB, 11/18/09,2

As always, running the wrong sql statement can bring your site down, use at your own risk.

I don’t think there’s an easy way to add a report or select statement to the Magento Admin. If so, maybe someone could post but otherwise you’ll have to use your other sql access to your site DB.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ralf Bernert
Jr. Member
 
Total Posts:  13
Joined:  2008-07-18
 

Go to

/app/code/core/Adminhtml/Report/grid.php

In line 52 ist the variable _subReportSize, just set that value to any other than 5 e.g. 20:

protected $_subReportSize = 20;

Next thing is: how to change that value by drop-down.

 
Magento Community Magento Community
Magento Community
Magento Community
 
DaveTheMage
Member
 
Total Posts:  46
Joined:  2010-10-26
 
Ralf Bernert - 05 July 2010 04:42 AM

Go to

/app/code/core/Adminhtml/Report/grid.php

In line 52 ist the variable _subReportSize, just set that value to any other than 5 e.g. 20:

protected $_subReportSize = 20;


Next thing is: how to change that value by drop-down.

This is exactly what I’m trying to do, but I’ve tried for two days now and I cannot make it change from the default of 5!!!

I’m assuming, in Magento 1.4.1.1, that the path you mean is /app/code/core/Mage/Adminhtml/Block/Report/Grid.php ?

Has anyone managed to change this default from 5 to something bigger?

(I have managed to add a drop-down selector to the report page, which I can then read the value of, but as I cannot make $_subReportSize have any affect, it’s pretty pointless right now.)

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
DaveTheMage
Member
 
Total Posts:  46
Joined:  2010-10-26
 

can’t delete this, so just blanking the text.

 
Magento Community Magento Community
Magento Community
Magento Community
 
DaveTheMage
Member
 
Total Posts:  46
Joined:  2010-10-26
 

Woohoo, I finally found it, phew!

Here’s how to change the number of items shown in the BestSellers reports...this is for Magento 1.4.11

I don’t know how to do this in the ‘local’ overrides yet, so these changes are to the Magento CORE files - you have been warned!
If someone can update this to say how to move these changes to ‘local’ then I’d be very grateful.

Note: If you just want a quick-fix and change the number of items shown per bestseller period, all you need to do is change the value of $_ratingLimit at the top of this file… /app/code/core/Mage/Sales/Model/Mysql4/Report/Bestsellers/Collection.php

==== CHANGE NUMBER OF PRODUCTS ON DASHBOARD ====

NOTE:
Just change the value inside the parenthesis as required.

File:
/app/code/core/Mage/Adminhtml/Block/Dashboard/Grid.php

Line 47:
$this->setDefaultLimit(5);

==== END DASHBOARD CHANGES ====

==== ADD A COMBO BOX TO BESTSELLERS REPORT TO SET ITEM COUNT ====

NOTE:
If you’re not bothered with a nice selection box on the report and just want to increase the
number of rows shown on the report, you can skip the changes shown here!
Add the following code. You can change the values to whatever you want, or add extra ones.
You’ll see other blocks of code looking almost identical; just put this at the end of them.
I have used a rather crude ‘if’ statement to detect if we are on the ‘bestsellers’ page,
and if so display this extra combo-box. Anyone know the proper way to do this?

File:
/app/code/core/Mage/Adminhtml/Block/Report/Filter/Form.php

Line 178ish:

// option to set number of child rows displayed
        if ( strstr($this->getUrl('*/*/*'), 'bestsellers') ) {
    
            $fieldset
->addField('entries_per_period''select', array(
                
'name'      => 'entries_per_period',
                
'options'   => array(
                    
'5' => Mage::helper('reports')->__('5'),
                    
'10' => Mage::helper('reports')->__('10'),
                    
'15' => Mage::helper('reports')->__('15'),
                    
'20' => Mage::helper('reports')->__('20'),
                    
'25' => Mage::helper('reports')->__('25'),
                    
'30' => Mage::helper('reports')->__('30')
                 ),
                
'label'     => Mage::helper('reports')->__('Items per period:'),
                
'title'     => Mage::helper('reports')->__('Items per period')
            ));
                
}
==== END ADD A COMBO BOX TO BESTSELLERS REPORT TO SET ITEM COUNT ====

==== CHANGE THE NUMBER OF ROWS SHOWN FOR EACH BESTSELLER PERIOD ====

NOTE:
If you just want a quick-fix and change the number of items shown per bestseller period,
all you need to do is change the value of $_ratingLimit at the top of this file.
For the combo-box feature added above, we need to add another function into this file.

File:
/app/code/core/Mage/Sales/Model/Mysql4/Report/Bestsellers/Collection.php

Line 56ish:

/**
     * DtM - function added 28-Feb-2011
     * Set number of child rows to display in report
     *
     * @param int ratingLimit    
     */
    public function setChildRows($ratingLimit 5)
    
{
        $this
->_ratingLimit = (int)$ratingLimit;
    
}

NOTE:
Now we need to make a change to the ‘abstract’ file that receives the form data.
Here we simply check to see if we have been passed a new value for our item count,
in which case we call the function we created to set the child rows value.
The bit of code here goes just after the block of code that looks like…
$resourceCollection = Mage::getResourceModel($this->getResourceCollectionName())

File:
/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php

Line 126ish:

// DtM - 28-Feb-2011 set number of child rows to entries_per_period
        //                                   this requires the 'setChildRows()' function to be added to
        //                                  /app/code/core/Mage/Sales/Model/Mysql4/Report/Bestsellers/Collection.php
        if ($filterData->getData('entries_per_period')>0{
                $resourceCollection
->setChildRows($filterData->getData('entries_per_period'));
        
}
==== END CHANGE THE NUMBER OF ROWS SHOWN FOR EACH BESTSELLER PERIOD ====
 
Magento Community Magento Community
Magento Community
Magento Community
 
JustMagento
Jr. Member
 
Total Posts:  2
Joined:  2011-05-16
 

Hey all. Doesn’t the products ordered report give the info you need?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ZenMasta
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2010-03-12
 

Thanks a lot for this. I’m really glad the basic tweak is simply editing $_ratingLimit

I’m comfortable editing that temporarily. It would still be fantastic if this was a core feature change in the future or a non core extension we could setup.

 
Magento Community Magento Community
Magento Community
Magento Community
 
xYcLoNe
Member
 
Avatar
Total Posts:  31
Joined:  2008-06-05
 
DaveTheMage - 28 February 2011 08:38 AM

Woohoo, I finally found it, phew!

Here’s how to change the number of items shown in the BestSellers reports...this is for Magento 1.4.11

I don’t know how to do this in the ‘local’ overrides yet, so these changes are to the Magento CORE files - you have been warned!
If someone can update this to say how to move these changes to ‘local’ then I’d be very grateful.

Note: If you just want a quick-fix and change the number of items shown per bestseller period, all you need to do is change the value of $_ratingLimit at the top of this file… /app/code/core/Mage/Sales/Model/Mysql4/Report/Bestsellers/Collection.php



==== CHANGE NUMBER OF PRODUCTS ON DASHBOARD ====

NOTE:
Just change the value inside the parenthesis as required.

File:
/app/code/core/Mage/Adminhtml/Block/Dashboard/Grid.php

Line 47:
$this->setDefaultLimit(5);

==== END DASHBOARD CHANGES ====


==== ADD A COMBO BOX TO BESTSELLERS REPORT TO SET ITEM COUNT ====

NOTE:
If you’re not bothered with a nice selection box on the report and just want to increase the
number of rows shown on the report, you can skip the changes shown here!
Add the following code. You can change the values to whatever you want, or add extra ones.
You’ll see other blocks of code looking almost identical; just put this at the end of them.
I have used a rather crude ‘if’ statement to detect if we are on the ‘bestsellers’ page,
and if so display this extra combo-box. Anyone know the proper way to do this?

File:
/app/code/core/Mage/Adminhtml/Block/Report/Filter/Form.php

Line 178ish:

// option to set number of child rows displayed
        if ( strstr($this->getUrl('*/*/*'), 'bestsellers') ) {
    
            $fieldset
->addField('entries_per_period''select', array(
                
'name'      => 'entries_per_period',
                
'options'   => array(
                    
'5' => Mage::helper('reports')->__('5'),
                    
'10' => Mage::helper('reports')->__('10'),
                    
'15' => Mage::helper('reports')->__('15'),
                    
'20' => Mage::helper('reports')->__('20'),
                    
'25' => Mage::helper('reports')->__('25'),
                    
'30' => Mage::helper('reports')->__('30')
                 ),
                
'label'     => Mage::helper('reports')->__('Items per period:'),
                
'title'     => Mage::helper('reports')->__('Items per period')
            ));
                
}
==== END ADD A COMBO BOX TO BESTSELLERS REPORT TO SET ITEM COUNT ====



==== CHANGE THE NUMBER OF ROWS SHOWN FOR EACH BESTSELLER PERIOD ====

NOTE:
If you just want a quick-fix and change the number of items shown per bestseller period,
all you need to do is change the value of $_ratingLimit at the top of this file.
For the combo-box feature added above, we need to add another function into this file.

File:
/app/code/core/Mage/Sales/Model/Mysql4/Report/Bestsellers/Collection.php

Line 56ish:
/**
     * DtM - function added 28-Feb-2011
     * Set number of child rows to display in report
     *
     * @param int ratingLimit    
     */
    public function setChildRows($ratingLimit 5)
    
{
        $this
->_ratingLimit = (int)$ratingLimit;
    
}

NOTE:
Now we need to make a change to the ‘abstract’ file that receives the form data.
Here we simply check to see if we have been passed a new value for our item count,
in which case we call the function we created to set the child rows value.
The bit of code here goes just after the block of code that looks like…
$resourceCollection = Mage::getResourceModel($this->getResourceCollectionName())

File:
/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php

Line 126ish:
// DtM - 28-Feb-2011 set number of child rows to entries_per_period
        //                                   this requires the 'setChildRows()' function to be added to
        //                                  /app/code/core/Mage/Sales/Model/Mysql4/Report/Bestsellers/Collection.php
        if ($filterData->getData('entries_per_period')>0{
                $resourceCollection
->setChildRows($filterData->getData('entries_per_period'));
        
}
==== END CHANGE THE NUMBER OF ROWS SHOWN FOR EACH BESTSELLER PERIOD ====

Kudos to the code..

This works perfectly.. Thank you very much..

 
Magento Community Magento Community
Magento Community
Magento Community
 
Chris_asa
Jr. Member
 
Total Posts:  2
Joined:  2011-08-25
 

Thank you for the code! I have a question - is it possible for the bestsellers report to only show products sold by a coupon code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tonythemediaguy
Member
 
Total Posts:  31
Joined:  2008-08-16
 

in 1.7 it’s app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php

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