Post by NTCommerce » Fri Jan 27, 2012 6:16 pm

My client has requested that the best seller module only lists the best sellers from the past 30 days,
Does anyone know if it is possible to adapt the bestsellers mod to suite ?
If so how would I go about this ?

Any thoughts would be greatly appreciated.

Nigel

New member

Posts

Joined
Tue Jun 14, 2011 7:51 pm

Post by eWarrior » Mon Apr 22, 2013 9:30 am

I know this is an old thread but I am also looking to implement this for a client (they are using v1.5.2.1).

Would anyone be able to offer assistance with the required modifications?

New member

Posts

Joined
Wed Aug 29, 2012 4:27 pm

Post by eWarrior » Fri Apr 26, 2013 5:19 pm

-
Last edited by eWarrior on Mon Mar 10, 2014 8:50 pm, edited 1 time in total.

New member

Posts

Joined
Wed Aug 29, 2012 4:27 pm

Post by daik01 » Fri Apr 26, 2013 5:49 pm

You have to change the query in getBestSellerProducts at the \catalog\model\catalog\product.php file. I think that adding a where clause like WHERE o.date_added > CURDATE() -30 should do the trick.

TOP 5 Opencart Extensions:
1:Opencart Reservations
2:Stock Report, import/export stock levels with Excel
3:3D Carousel
4:Product Price Changer by Category
5:Set price Inclusive Taxes
DEMO SHOP


Active Member

Posts

Joined
Sun Oct 21, 2012 3:18 am


Post by storm-cloud » Sat Apr 27, 2013 5:56 pm

Thank you for the reply daik01!

I tried your suggested code but unfortunately I was not able to get this to work. I researched this a little further and came up with o.date_added >= DATE_SUB(NOW(), INTERVAL 30 DAY).

The complete query was changed from:

$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:

$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 o.date_added >= DATE_SUB(NOW(), INTERVAL 30 DAY) 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);

This seems to be doing the trick but admittedly my SQL skills could use some work. Would there be a better method than this or is there anything in the above code that may cause issues?

Active Member

Posts

Joined
Wed Feb 22, 2012 8:07 am

Post by ninad_jad » Wed Apr 20, 2016 4:05 pm

Hi,

i tried this code for oc2.1.0.2, but nothing happened, i cleared modifications and all but still same regular result, any one have solution for oc2.1.0.2 to get best sellers for last week or month

New member

Posts

Joined
Mon Dec 30, 2013 3:11 pm

Post by straightlight » Fri May 13, 2016 11:23 pm


Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by websiteworld » Thu Dec 22, 2016 5:59 am

ninad_jad wrote:Hi,

i tried this code for oc2.1.0.2, but nothing happened, i cleared modifications and all but still same regular result, any one have solution for oc2.1.0.2 to get best sellers for last week or month
Same here, doesn't do anything in Opencart 2.3

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Who is online

Users browsing this forum: No registered users and 26 guests