Bug du module de statistiques - Prestashop

 |  Administrator

Le module de statistique "Visiteurs en ligne" de prestashop comporte une erreur au niveau de la requête SQL qui ne renvoi donc aucun résultats.

Pur corriger le problème remplacez les 2 fonctions du fichier modules/statslive/statslive.php :

private function getCustomersOnline()
    {
        return Db::getInstance()->ExecuteS('
        SELECT u.id_customer, u.firstname, u.lastname, pt.name as page
        FROM `'._DB_PREFIX_.'connections` c
        LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
        LEFT JOIN `'._DB_PREFIX_.'page` p ON p.id_page = cp.id_page
        LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON p.id_page_type = pt.id_page_type
        INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
        INNER JOIN `'._DB_PREFIX_.'customer` u ON u.id_customer = g.id_customer
        WHERE cp.`time_end` IS NULL
        AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
        GROUP BY c.id_connections
        ORDER BY u.firstname, u.lastname');
    }
   
    private function getVisitorsOnline()
    {
        return Db::getInstance()->ExecuteS('
        SELECT c.id_guest, c.ip_address, c.date_add, c.http_referer, pt.name as page
        FROM `'._DB_PREFIX_.'connections` c
        LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
        LEFT JOIN `'._DB_PREFIX_.'page` p ON p.id_page = cp.id_page
        LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON p.id_page_type = pt.id_page_type
        INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
        WHERE (g.id_customer IS NULL OR g.id_customer = 0)
        AND cp.`time_end` IS NULL
        AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
        GROUP BY c.id_connections
        ORDER BY c.date_add DESC');
    }

Par :

private function getCustomersOnline()
    {   
        $today = date('Y-m-d H:i:s');
        return Db::getInstance()->ExecuteS("
        SELECT u.id_customer, u.firstname, u.lastname, pt.name as page
        FROM `"._DB_PREFIX_."connections` c
        LEFT JOIN `"._DB_PREFIX_."connections_page` cp ON c.id_connections = cp.id_connections
        LEFT JOIN `"._DB_PREFIX_."page` p ON p.id_page = cp.id_page
        LEFT JOIN `"._DB_PREFIX_."page_type` pt ON p.id_page_type = pt.id_page_type
        INNER JOIN `"._DB_PREFIX_."guest` g ON c.id_guest = g.id_guest
        INNER JOIN `"._DB_PREFIX_."customer` u ON u.id_customer = g.id_customer
        WHERE cp.`time_end` IS NULL
        AND TIME_TO_SEC(TIMEDIFF('".$today."', cp.`time_start`)) < 900
        GROUP BY c.id_connections
        ORDER BY u.firstname, u.lastname");
    }
   
    private function getVisitorsOnline()
    {
        $today = date('Y-m-d H:i:s');
        return Db::getInstance()->ExecuteS("
        SELECT c.id_guest, c.ip_address, c.date_add, c.http_referer, pt.name as page
        FROM `"._DB_PREFIX_."connections` c
        LEFT JOIN `"._DB_PREFIX_."connections_page` cp ON c.id_connections = cp.id_connections
        LEFT JOIN `"._DB_PREFIX_."page` p ON p.id_page = cp.id_page
        LEFT JOIN `"._DB_PREFIX_."page_type` pt ON p.id_page_type = pt.id_page_type
        INNER JOIN `"._DB_PREFIX_."guest` g ON c.id_guest = g.id_guest
        WHERE (g.id_customer IS NULL OR g.id_customer = 0)
        AND cp.`time_end` IS NULL
        AND TIME_TO_SEC(TIMEDIFF('".$today."', cp.`time_start`)) < 900
        GROUP BY c.id_connections
        ORDER BY c.date_add DESC");
    }

Souscrire à Notre Lettre d'Information

Média Conseil et Création créateur de site Internet

© 2000- MC&C. Tous droits réservés.
Réalisé par MC&C