Page 1 of 1

Bestseller sort order

Posted: Sun Jan 15, 2012 5:19 am
by karlpers
I have some doubts on how the bestseller list are presented. Is it how many times a product has been sold, or is it the total amount sold? I dont really understand how the module works.

Eg. My reports>products>purchased:
The product name 8 - 210 sales - $8,389.50 total
The product name 2 - 4 sales - $539.80 total
The product name 1 - 1 sale - $39.95 total

My bestseller list:
The product name 2
The product name 8
The product name 1

If I purchase the Product name 8, it goes up on top, but the same with Product 2. For me it looks like it shows "latest sold products"

Does my catche has something to do with this? Its a fresh installed store.. Anyone with the same problem?

Re: Bestseller sort order

Posted: Mon Jan 30, 2012 6:49 pm
by Molok
Hi,

I have the same question.
It doesn't make sense if the Bestseller list is in fact generated as a list of last sold items.

Like the name says the Bestseller module should generate a list of the best selling items in terms of numbers of items sold.

Re: Bestseller sort order

Posted: Mon Jan 30, 2012 10:19 pm
by Qphoria
It is "Best" sellers. It is sorted by MOST sold item, not most recent.
If you sold
5x ipods
2x hp laptops
4x Ipads
6x TV's

it would list them in this order, greatest to least:
1. TV
2. ipods
3. ipads
4. hp laptops

This is and has always been.

There is a mod for "Recently Purchased" here if you want that:
http://www.opencart.com/index.php?route ... ion_id=444

Re: Bestseller sort order

Posted: Mon Jan 30, 2012 11:27 pm
by karlpers
Well, not a big issue any more though, but as Qphoria says is how I expected the list to be. But it doesnt, as I describe in the first post the list in my case is a bit wierd where the most sold (both in Quantity and Total isnt at position 1 in the list.

Maybe there is some circumstances which makes my store shows the bestseller a bit different..

Re: Bestseller sort order

Posted: Tue Mar 13, 2012 5:05 am
by PinkPearl
Qphoria wrote:It is "Best" sellers. It is sorted by MOST sold item, not most recent.
If you sold
5x ipods
2x hp laptops
4x Ipads
6x TV's

it would list them in this order, greatest to least:
1. TV
2. ipods
3. ipads
4. hp laptops

This is and has always been.

There is a mod for "Recently Purchased" here if you want that:
http://www.opencart.com/index.php?route ... ion_id=444
I would like to follow up on this because my "Best sellers" list certainly isn't sorted by the most items sold. In fact it doesn't seem to be sorted by anything at all. Is this a glitch? I am using Version 1.5.1.3

Thanks for your attention.

Re: Bestseller sort order

Posted: Tue Mar 13, 2012 5:56 am
by rph
I was just looking at this the other day. Whether it's wrong is probably debatable (it's number of customers who bought a product versus the number of the product sold) but the issue comes from doing a COUNT instead of a SUM.

To alter it in the getBestSellerProducts function in /catalog/model/catalog/product.php change:

Code: Select all

$query = $this->db->query("SELECT op.product_id, COUNT(*) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); 
to:

Code: Select all

$query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); 
I haven't tested the changes for query speed so keep that in mind.

Re: Bestseller sort order

Posted: Wed Mar 14, 2012 12:44 am
by PinkPearl
Thanks RPH, I will give this a try.

Re: Bestseller sort order

Posted: Sat Aug 18, 2012 5:09 am
by ultraburner
I tried this code on my store and it didnt change the order of the items displayed.

Is there something wrong with this code?

Cheers Simon

Re: Bestseller sort order

Posted: Sat Aug 18, 2012 5:25 am
by rph
You'll need to clear out your cache files in /system/cache before there are changes (or wait a couple hours for it to happen automatically).

On a semi-related note I've released Bestsellers Advanced which allows bestselling products to be shown by category.