Merge branch 'ticket-criteo' into develop

This commit is contained in:
Marion Muszynski 2016-07-28 12:30:04 +02:00
commit fe85712667

View File

@ -454,7 +454,7 @@ class Criteo_bbb extends Module
WHERE `id_product` IN ('.implode(', ', $id_products).')
AND `id_sale` != 0
') as $row) {
$products_sales[(int) $row['id_product']] = (int) $row['id_sale'];
$products_sales[(int) $row['id_product']] = (int) $row['id_product'];
}
if(count($products_sales) == 0) {
@ -466,17 +466,19 @@ class Criteo_bbb extends Module
foreach ($products as $product) {
if(isset($products_sales[$product['id_product']])) {
if(!isset($product_result[$products_sales[$product['id_product']]])) {
$product_result[$products_sales[$product['id_product']]] = 0;
$product_result[$products_sales[$product['id_product']]]['price'] = 0;
$product_result[$products_sales[$product['id_product']]]['quantity'] = 0;
}
$product_obj = new Product((int)$product['id_product']);
$price = $product_obj->getPrice(true, ($product['id_product_attribute'] ? $product['id_product_attribute'] : (int)Product::getDefaultAttribute($product_obj->id)), 2);
$product_result[$products_sales[$product['id_product']]] += $price * (int) $product['quantity'];
$product_result[$products_sales[$product['id_product']]]['price'] += $price * (int) $product['quantity'];
$product_result[$products_sales[$product['id_product']]]['quantity'] += (int) $product['quantity'];
unset($product_obj);
}
}
foreach($product_result as $id_product => $value) {
$strproducts .= '{ id: '.$id_product.', price: '.$value.', quantity: 1 },';
$strproducts .= '{ id: '.$id_product.', price: '.$value['price'].', quantity: '.$value['quantity'].' },';
}
$strproducts = Tools::substr($strproducts, 0, -1);