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
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
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
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?
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?
Contribution: http://forum.opencart.com/viewtopic.php?f=123&t=162506
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Same here, doesn't do anything in Opencart 2.3ninad_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
Who is online
Users browsing this forum: No registered users and 22 guests