fix soucis dupdate stat global en dehors du foreach
This commit is contained in:
parent
cb5e38ee47
commit
648fe3a508
@ -136,39 +136,39 @@ foreach ($langs as $iso => $id_lang) {
|
||||
NOW()
|
||||
)
|
||||
');
|
||||
}
|
||||
|
||||
// stats for each lang (total_sales_wt, total_products)
|
||||
$total = Db::getInstance()->getRow('
|
||||
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`, SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100)), 6)) AS `total_unit_sales`
|
||||
FROM `'._DB_PREFIX_.'order_detail` d
|
||||
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
|
||||
WHERE d.`product_id` IN (
|
||||
SELECT `id_product`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache`
|
||||
WHERE `id_sale` = '.(int) $sale['id_sale'].'
|
||||
)
|
||||
AND o.valid = 1
|
||||
AND o.`id_lang` = '.(int) $id_lang.'
|
||||
');
|
||||
|
||||
// stats for each lang (total_sales_wt, total_products)
|
||||
$total = Db::getInstance()->getRow('
|
||||
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`, SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100)), 6)) AS `total_unit_sales`
|
||||
FROM `'._DB_PREFIX_.'order_detail` d
|
||||
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
|
||||
WHERE d.`product_id` IN (
|
||||
SELECT `id_product`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache`
|
||||
Db::getInstance()->ExecuteS('
|
||||
DELETE FROM `'._DB_PREFIX_.'privatesale_livestats_sale_lang`
|
||||
WHERE `id_sale` = '.(int) $sale['id_sale'].'
|
||||
)
|
||||
AND o.valid = 1
|
||||
AND o.`id_lang` = '.(int) $id_lang.'
|
||||
');
|
||||
AND `id_lang` = '.(int) $id_lang
|
||||
);
|
||||
|
||||
Db::getInstance()->ExecuteS('
|
||||
DELETE FROM `'._DB_PREFIX_.'privatesale_livestats_sale_lang`
|
||||
WHERE `id_sale` = '.(int) $sale['id_sale'].'
|
||||
AND `id_lang` = '.(int) $id_lang
|
||||
);
|
||||
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'privatesale_livestats_sale_lang`
|
||||
VALUES (
|
||||
'.(int) $sale['id_sale'].',
|
||||
'.(int) $id_lang.',
|
||||
'.(float) $total['total_sales_wt'].',
|
||||
'.(int) $total['total_products'].',
|
||||
NOW()
|
||||
)
|
||||
');
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'privatesale_livestats_sale_lang`
|
||||
VALUES (
|
||||
'.(int) $sale['id_sale'].',
|
||||
'.(int) $id_lang.',
|
||||
'.(float) $total['total_sales_wt'].',
|
||||
'.(int) $total['total_products'].',
|
||||
NOW()
|
||||
)
|
||||
');
|
||||
}
|
||||
// foreach sales
|
||||
}
|
||||
// fin foreach lang
|
||||
|
||||
|
@ -125,39 +125,39 @@ foreach ($langs as $iso => $id_lang) {
|
||||
NOW()
|
||||
)
|
||||
');
|
||||
}
|
||||
|
||||
// stats for each lang (total_sales_wt, total_products)
|
||||
$total = Db::getInstance()->getRow('
|
||||
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`, SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100)), 6)) AS `total_unit_sales`
|
||||
FROM `'._DB_PREFIX_.'order_detail` d
|
||||
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
|
||||
WHERE d.`product_id` IN (
|
||||
SELECT `id_product`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache`
|
||||
WHERE `id_sale` = '.(int) $sale['id_sale'].'
|
||||
)
|
||||
AND o.valid = 1
|
||||
AND o.`id_lang` = '.(int) $id_lang.'
|
||||
');
|
||||
|
||||
// stats for each lang (total_sales_wt, total_products)
|
||||
$total = Db::getInstance()->getRow('
|
||||
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`, SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100)), 6)) AS `total_unit_sales`
|
||||
FROM `'._DB_PREFIX_.'order_detail` d
|
||||
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
|
||||
WHERE d.`product_id` IN (
|
||||
SELECT `id_product`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache`
|
||||
Db::getInstance()->ExecuteS('
|
||||
DELETE FROM `'._DB_PREFIX_.'privatesale_livestats_sale_lang`
|
||||
WHERE `id_sale` = '.(int) $sale['id_sale'].'
|
||||
)
|
||||
AND o.valid = 1
|
||||
AND o.`id_lang` = '.(int) $id_lang.'
|
||||
');
|
||||
AND `id_lang` = '.(int) $id_lang
|
||||
);
|
||||
|
||||
Db::getInstance()->ExecuteS('
|
||||
DELETE FROM `'._DB_PREFIX_.'privatesale_livestats_sale_lang`
|
||||
WHERE `id_sale` = '.(int) $sale['id_sale'].'
|
||||
AND `id_lang` = '.(int) $id_lang
|
||||
);
|
||||
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'privatesale_livestats_sale_lang`
|
||||
VALUES (
|
||||
'.(int) $sale['id_sale'].',
|
||||
'.(int) $id_lang.',
|
||||
'.(float) $total['total_sales_wt'].',
|
||||
'.(int) $total['total_products'].',
|
||||
NOW()
|
||||
)
|
||||
');
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'privatesale_livestats_sale_lang`
|
||||
VALUES (
|
||||
'.(int) $sale['id_sale'].',
|
||||
'.(int) $id_lang.',
|
||||
'.(float) $total['total_sales_wt'].',
|
||||
'.(int) $total['total_products'].',
|
||||
NOW()
|
||||
)
|
||||
');
|
||||
}
|
||||
// fin foreach sales
|
||||
}
|
||||
// fin foreach lang
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user