Merge branch 'ticket-10444' into develop

This commit is contained in:
Marion Muszynski 2016-07-12 17:59:41 +02:00
commit 4b46c90929

View File

@ -281,11 +281,6 @@ class MakeStats {
WHERE product_id IN ("'.implode('","', $ids_products).'")';
$res = Db::getInstance()->ExecuteS($req);
/*$ids_od = array();
foreach($res as $k => $r) {
$ids_od[] = $res[$k]['product_id'];
}
$ids_no_od = array_diff($ids_products, $ids_od);*/
$req2 = 'SELECT
p.id_product as product_id, p.price as product_price, p.price as product_price, p.ean13 as product_ean13, p.reference as product_reference, p.supplier_reference as product_supplier_reference,
p.weight as product_weight, pl.name as product_name_base,
@ -299,17 +294,16 @@ class MakeStats {
WHERE p.id_product IN ("'.implode('","', $ids_products).'")';
$res2 = Db::getInstance()->ExecuteS($req2);
$ids_in_order = array();
foreach($res as $k => $r) {
$ids_in_order[$res[$k]['product_id']] = $res[$k]['product_attribute_id'];
}
foreach ($res2 as $k => $value) {
if(isset($value['product_attribute_id'])
&& $key = array_search($value['product_attribute_id'], array_column($res, 'product_attribute_id'))
&& $key
&& $res[$key]['product_id'] == $value['product_id']
) {
if(isset($value['product_attribute_id']) && in_array($value['product_attribute_id'], $ids_in_order)) {
unset($res2[$k]);
} elseif (!isset($value['product_attribute_id'])
&& $key = array_search($value['product_id'], array_column($res, 'product_id'))
&& $key
&& (int)$res[$key]['product_attribute_id'] == 0
&& array_key_exists($value['product_id'], $ids_in_order)
&& $ids_in_order[$value['product_id']] == 0
){
unset($res2[$k]);
}