Jump to content

Graphic on the home page don't work


Recommended Posts

On the 16th of June we upgraded an online shop from 1.6 to 1.7.8.3. Today it works correctly, orders are coming in, payments are being made, but this data is not reflected in the graph on the home page. As you can see in the attached image, the graph was working until we upgraded and I can't find a way to fix it. It's a pain as it makes it very difficult to keep the statistics at the end of the month. I think we have the latest version of the module installed but they can't support me as the subscription has expired. 

Can anyone shed some light on the matter?

1858972650_Sinttulo-1.jpg.02541740d0d80bd3cacac4537d0f759b.jpg

Link to comment
Share on other sites

Hi,

Search for "dashboard" in the modules section there must be 4 modules to be reset.
The modules are as follows:

- Dashboard Activity
- Dashboard Goals
- Dashboard Products
- Dashboard Trends

I hope that I could help.
Have a nice day

Kind regards,
Leo

Link to comment
Share on other sites

I found this post that seems work. Disabling the generation of invoices seems to have affected the statistics. I'm replacing "invoice_date" with "date_add" which is the date when the order is created 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; }

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...