PrestaShop / ganalytics

Gain clear insights into important metrics about your customers, using Google Analytics in PrestaShop 1.6.
11 stars 43 forks source link

Old orders are sent to Google Analytics if module is not installed from start #79

Closed morgan-enetb closed 8 years ago

morgan-enetb commented 8 years ago

With this code in hookBackOfficeHeader, each time you consult order and this order is not in the database ps_ganalytics, a record is created and send old transaction.It should not send orders made before the module installation


if ($this->context->controller->controller_name == 'AdminOrders')
            {
                if (Tools::getValue('id_order'))
                {
                    $ga_order_sent = Db::getInstance()->getValue('SELECT id_order FROM `'._DB_PREFIX_.'ganalytics` WHERE id_order = '.(int)Tools::getValue('id_order'));
                    if ($ga_order_sent === false)
                        Db::getInstance()->Execute('INSERT IGNORE INTO `'._DB_PREFIX_.'ganalytics` (id_order, id_shop, sent, date_add) VALUES ('.(int)Tools::getValue('id_order').', '.(int)$this->context->shop->id.', 0, NOW())');
                }
                else
cedricfontaine commented 8 years ago

You're right, I added a verification to add only orders less than 1 day old.

vincentbz commented 8 years ago

Agreed for this, possible to have a core review by PS ? @Quetzacoalt91 for example :dancers:

cedricfontaine commented 8 years ago

It has already been implemented in the module.

julienbourdeau commented 8 years ago

Closed with #83