Jump to content

Dashboard statistic doesn't work [PS.1.7.8]


Andrejkov

Recommended Posts

  • 11 months later...

Maybe its too late. But there is fix.

Prestashop count only orders with generated invoice. If you want to avoid that change code in /controller/AdminStatsController.php on line 267.

 

public static function getOrders($date_from, $date_to, $granularity = false)
{
    if ($granularity == 'day') {
        $orders = [];
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
            '
            SELECT LEFT(`date_add`, 10) AS date, COUNT(*) AS orders
            FROM `' . _DB_PREFIX_ . 'orders` o
            WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59"
            ' . 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 = [];
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
            '
            SELECT LEFT(`date_add`, 7) AS date, COUNT(*) AS orders
            FROM `' . _DB_PREFIX_ . 'orders` o
            WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59"
            ' . 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
            WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59"
            ' . Shop::addSqlRestriction(false, 'o')
        );
    }

    return $orders;
}



 

  • Thanks 1
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...