zumbador 2 Posted August 25, 2015 Hi, are there any new suggestions about how to get the dashboard to show sales volume. mine is at zero. The graphs seem to be working ok as well as the Orders, Cart Value,Visits and Conversion Rate. I have tried everything icould find on teh forum to no avail. Prestashop v1.6.1.1 Share this post Link to post Share on other sites
vekia 8,950 Posted August 25, 2015 in statistics you see proper sales count? Share this post Link to post Share on other sites
zumbador 2 Posted August 25, 2015 Wow! quickest response ever! Yes i do see the correct sales count. Share this post Link to post Share on other sites
webbwayne 2 Posted August 25, 2015 I'm having the same issue. Just started today. Not sure what's going on. All my sales stats say Zero except visits and conversion rate. The graph is working just fine. Share this post Link to post Share on other sites
flyclothing 31 Posted August 25, 2015 I believe there was an update to the dashboard module and it is now causing the issue. I am having the same issue after updating. http://img42.com/5SLbE Only live for 10 minutes. Share this post Link to post Share on other sites
vekia 8,950 Posted August 25, 2015 i see seems like its a module bug if you will downgrade it, do you see the same problems? Share this post Link to post Share on other sites
flyclothing 31 Posted August 25, 2015 I would try that but I am not sure which module it actually is and dont see a "downgrade" function within the right-click options. Share this post Link to post Share on other sites
webbwayne 2 Posted August 26, 2015 I believe it is the Dashboard Trends module. How do we downgrade a module? Just curious Share this post Link to post Share on other sites
markaussie 13 Posted August 28, 2015 Hi, Easiest way I found to downgrade this module besides using a backup --- download latest PS version 1.6.1.1 to your PC --- Extract on PC ---- Go to Modules folder --- find and use the dashtrends module (0.7.5) from this download to replace the updated 0.8 version on your web server. Don't update it until fixed. (It should show version 0.7.5 in BO Modules now) I have done above and all working fine now. It's missing the improvements added (ex tax wording and decimal point) but it shows Sales, Cart Value and Profit. Share this post Link to post Share on other sites
flyclothing 31 Posted August 30, 2015 Yeah, there's definitely a bug in the newest version. I just found an old version and replaced the updated module and it's working again. Does anyone test this stuff? #getyourshittogether #dashtrends 2 Share this post Link to post Share on other sites
Kopy 0 Posted October 8, 2015 I found this post and few similar other that Prestashop doesn't show sales statistics. I am experiencing the same problem even after upgrading Dashboard trends module to v0.8.1.I only see stats for orders that has invoice generated. I don't generate invoice for all orders, but I need to see statistics. I have two store - one is 1.6.0.9 and other 16.1.1 both are having the same problem with sales statistics. Does anybody has any clue how to enable sales statistics for all orders, not just for those with invoices? Share this post Link to post Share on other sites
Janekx 3 Posted May 2, 2016 Why does dashtrends not calc net profit from wholesale proce - price - fees? And still count in some Average gross margin percentage? Share this post Link to post Share on other sites
djpat99 8 Posted May 9, 2016 (edited) in statistics you see proper sales count? Hello, I am having this problem and it isn't recording in the sales count in statistics either. The only thing I had changed prior to this problem starting is a timezone as the time was an hour out since daylight savings here in the UK. I read somewhere else that I had to change the time zone, now sales numbers are not recorded anywhere, but the orders are being taken. I am on 1.6.1.1 Thanks for looking. EDIT: Ignore this. I just remembered that I had also changed the settings so an invoice is only available after shipment where as I allowed it from the initial order so this may be the issue. We wouldn't have shipped anything over the weekend so that wouldn't show on our sales now. Edited May 9, 2016 by djpat99 (see edit history) Share this post Link to post Share on other sites
Biospot Romania 0 Posted October 28, 2016 I have problem with visits and conversion rate... is showing 0 . Can someone help me to ? Thanks Share this post Link to post Share on other sites
flyclothing 31 Posted October 28, 2016 I dont know if this module will ever work/be fixed. For as long as I have used Prestashop, it hasnt worked correctly: never has correct month. 1 Share this post Link to post Share on other sites
Israel A Santos 3 Posted October 18, 2017 I have the same problem... downgrade did not work The problem started on 2017-10-16 All days prior to 16 are ok 16,17 and 18 = 0 sales :/ - In AdminStats > Sales and Orders = ok ( click here and see print ) - In Dashboard = Error ( click here and see print ) Prestashop 1.6.1.17 Share this post Link to post Share on other sites
vnasp 0 Posted October 21, 2017 On 18/10/2017 at 2:49 PM, Israel A Santos said: I have the same problem... downgrade did not work The problem started on 2017-10-16 All days prior to 16 are ok 16,17 and 18 = 0 sales :/ - In AdminStats > Sales and Orders = ok ( click here and see print ) - In Dashboard = Error ( click here and see print ) Prestashop 1.6.1.17 Hi! We have the same problem. It started at 2017-10-16 too. And 0 sales,, 0 visits, 0 all, however we have sales! Did you find a solution? PS 1.6.0.9 Share this post Link to post Share on other sites
Mercader Virtual 8 Posted August 25, 2019 (edited) Tested in Prestashop 1.7.5.1, but probably same problem happens on other versions: Looking at the code, the problem is quite obvious. Prestashop assumes that "orders.invoice_date" is present. So if the invoice date is not set on your orders (let say you have disabled the invoices), the query won't find any records to sum, thus in some cases you get $0, or less than you expect. I fixed it by replacing invoice_date with "date_add" which is the date when the order is created. Also the query checks if the order is valid. With this fix there's no need to depend on invoices anymore. What to do: You need to update get getTotalSales method in: controllers/admin/AdminStatsController.php With: public static function getTotalSales($date_from, $date_to, $granularity = false) { if ($granularity == 'day') { $sales = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 10) AS date, SUM(total_products / o.conversion_rate) AS sales FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 10)' ); foreach ($result as $row) { $sales[strtotime($row['date'])] = $row['sales']; } return $sales; } elseif ($granularity == 'month') { $sales = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 7) AS date, SUM(total_products / o.conversion_rate) AS sales FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 7)' ); foreach ($result as $row) { $sales[strtotime($row['date'] . '-01')] = $row['sales']; } return $sales; } else { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue( ' SELECT SUM(total_products / o.conversion_rate) FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') ); } } Same thing happens with # of Orders, so here's the code (also in AdminStatsController.php😞 public static function getOrders($date_from, $date_to, $granularity = false) { if ($granularity == 'day') { $orders = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 10) AS date, COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 10)' ); foreach ($result as $row) { $orders[strtotime($row['date'])] = $row['orders']; } return $orders; } elseif ($granularity == 'month') { $orders = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 7) AS date, COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 7)' ); foreach ($result as $row) { $orders[strtotime($row['date'] . '-01')] = $row['orders']; } return $orders; } else { $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue( ' SELECT COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') ); } return $orders; } Hope it helps. Good luck. Edited August 25, 2019 by Mercader Virtual (see edit history) 5 Share this post Link to post Share on other sites
Nesta92 0 Posted June 24, 2020 On 8/25/2019 at 4:39 AM, Mercader Virtual said: Tested in Prestashop 1.7.5.1, but probably same problem happens on other versions: Looking at the code, the problem is quite obvious. Prestashop assumes that "orders.invoice_date" is present. So if the invoice date is not set on your orders (let say you have disabled the invoices), the query won't find any records to sum, thus in some cases you get $0, or less than you expect. I fixed it by replacing invoice_date with "date_add" which is the date when the order is created. Also the query checks if the order is valid. With this fix there's no need to depend on invoices anymore. What to do: You need to update get getTotalSales method in: controllers/admin/AdminStatsController.php With: public static function getTotalSales($date_from, $date_to, $granularity = false) { if ($granularity == 'day') { $sales = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 10) AS date, SUM(total_products / o.conversion_rate) AS sales FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 10)' ); foreach ($result as $row) { $sales[strtotime($row['date'])] = $row['sales']; } return $sales; } elseif ($granularity == 'month') { $sales = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 7) AS date, SUM(total_products / o.conversion_rate) AS sales FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 7)' ); foreach ($result as $row) { $sales[strtotime($row['date'] . '-01')] = $row['sales']; } return $sales; } else { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue( ' SELECT SUM(total_products / o.conversion_rate) FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') ); } } Same thing happens with # of Orders, so here's the code (also in AdminStatsController.php😞 public static function getOrders($date_from, $date_to, $granularity = false) { if ($granularity == 'day') { $orders = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 10) AS date, COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 10)' ); foreach ($result as $row) { $orders[strtotime($row['date'])] = $row['orders']; } return $orders; } elseif ($granularity == 'month') { $orders = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 7) AS date, COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 7)' ); foreach ($result as $row) { $orders[strtotime($row['date'] . '-01')] = $row['orders']; } return $orders; } else { $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue( ' SELECT COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') ); } return $orders; } Hope it helps. Good luck. Hi ! Thank you for the tip. Is this method is retroactive ? Will it display old orders after the update of these 2 files ? Thanks a lot ! Share this post Link to post Share on other sites
Israel A Santos 3 Posted June 24, 2020 26 minutes ago, Nesta92 said: Hi ! Thank you for the tip. Is this method is retroactive ? Will it display old orders after the update of these 2 files ? Thanks a lot ! Possibly! Because the change filters data from the table, based on the date. Create a backup of this file before making any changes. Test and bring us your feedback Share this post Link to post Share on other sites
Nesta92 0 Posted June 24, 2020 Just now, Israel A Santos said: Possibly! Because the change filters data from the table, based on the date. Create a backup of this file before making any changes. Test and bring us your feedback Thank you, just tried on Prestashop v1.7.6.5 but orders stats are still not correct. It only count orders with generated invoices Share this post Link to post Share on other sites
fercaldas 2 Posted September 28, 2020 this solution not works for me... Version 1.7.6.7 neither after clean cache and update PHP. It was PHP 7.1 and I updated to 7.2 trying to solve the issue. It was working well, but day 6-Sep stop to show sales and order stats. Don't run any update this day or later... I already reseted the module millions of times and did NOTHING with the system this day. I realy cannot find the issue... Share this post Link to post Share on other sites
Mistrz Yoda 1 Posted October 1, 2020 (edited) On 8/25/2019 at 4:39 AM, Mercader Virtual said: Tested in Prestashop 1.7.5.1, but probably same problem happens on other versions: Looking at the code, the problem is quite obvious. Prestashop assumes that "orders.invoice_date" is present. So if the invoice date is not set on your orders (let say you have disabled the invoices), the query won't find any records to sum, thus in some cases you get $0, or less than you expect. I fixed it by replacing invoice_date with "date_add" which is the date when the order is created. Also the query checks if the order is valid. With this fix there's no need to depend on invoices anymore. What to do: You need to update get getTotalSales method in: controllers/admin/AdminStatsController.php With: public static function getTotalSales($date_from, $date_to, $granularity = false) { if ($granularity == 'day') { $sales = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 10) AS date, SUM(total_products / o.conversion_rate) AS sales FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 10)' ); foreach ($result as $row) { $sales[strtotime($row['date'])] = $row['sales']; } return $sales; } elseif ($granularity == 'month') { $sales = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 7) AS date, SUM(total_products / o.conversion_rate) AS sales FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 7)' ); foreach ($result as $row) { $sales[strtotime($row['date'] . '-01')] = $row['sales']; } return $sales; } else { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue( ' SELECT SUM(total_products / o.conversion_rate) FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') ); } } Same thing happens with # of Orders, so here's the code (also in AdminStatsController.php😞 public static function getOrders($date_from, $date_to, $granularity = false) { if ($granularity == 'day') { $orders = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 10) AS date, COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 10)' ); foreach ($result as $row) { $orders[strtotime($row['date'])] = $row['orders']; } return $orders; } elseif ($granularity == 'month') { $orders = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT LEFT(`date_add`, 7) AS date, COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' GROUP BY LEFT(`date_add`, 7)' ); foreach ($result as $row) { $orders[strtotime($row['date'] . '-01')] = $row['orders']; } return $orders; } else { $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue( ' SELECT COUNT(*) AS orders FROM `' . _DB_PREFIX_ . 'orders` o LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON o.current_state = os.id_order_state WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" AND os.logable = 1 AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') ); } return $orders; } Hope it helps. Good luck. Dashtrends worked! PS 1.7.6.6 Tnx! Dashgoals not working :(. edit: found a solution here: https://github.com/PrestaShop/PrestaShop/issues/9662#issuecomment-475696541 Edited October 1, 2020 by Mistrz Yoda (see edit history) Share this post Link to post Share on other sites