This commit is contained in:
Marion Muszynski 2017-11-22 16:31:51 +01:00
parent 5a9d780365
commit 8ae9fb7dd2
3 changed files with 141 additions and 68 deletions

View File

@ -111,24 +111,24 @@ class AdminAntWp extends AdminTab
$ean = trim($line[0]); $ean = trim($line[0]);
$products[$ean] = array( $products[$ean] = array(
'ean' => $ean, 'ean' => $ean,
'supplier_ref' => trim($line[1]), 'supplier_ref' => trim((String)utf8_encode($line[1])),
'name_ha' => trim($line[2]), 'name_ha' => trim((String)utf8_encode($line[2])),
'quantity' => trim($line[3]), 'quantity' => trim($line[3]),
'ppc' => trim($line[4]), 'ppc' => trim((float)$line[4]),
'prix_ha' => trim($line[5]), 'prix_ha' => trim((float)$line[5]),
'name_attribute_ha' => trim($line[6]) 'name_attribute_ha' => trim((String)$line[6])
); );
$eans[] = $ean; $eans[] = $ean;
} else { } else {
$ref = trim($line[1]); $ref = trim((String)utf8_encode($line[1]));
$products[$ref] = array( $products[$ref] = array(
'ean' => trim($line[0]), 'ean' => trim($line[0]),
'supplier_ref' => $ref, 'supplier_ref' => $ref,
'name_ha' => trim($line[2]), 'name_ha' => trim((String)utf8_encode($line[2])),
'quantity' => trim($line[3]), 'quantity' => trim($line[3]),
'ppc' => trim($line[4]), 'ppc' => trim((float)$line[4]),
'prix_ha' => trim($line[5]), 'prix_ha' => trim((float)$line[5]),
'name_attribute_ha' => trim($line[6]) 'name_attribute_ha' => trim((String)utf8_encode($line[6]))
); );
$refs[] = $ref; $refs[] = $ref;
} }
@ -181,7 +181,7 @@ class AdminAntWp extends AdminTab
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` ac LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` ac
ON (ac.`id_product_attribute` = at.`id_product_attribute`) ON (ac.`id_product_attribute` = at.`id_product_attribute`)
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
ON (al.`id_attribute` = ac.`id_attribute` AND al.`id_land` = 2) ON (al.`id_attribute` = ac.`id_attribute` AND al.`id_lang` = 2)
WHERE at.`ean13` IN ("'.implode('","',$eans).'") WHERE at.`ean13` IN ("'.implode('","',$eans).'")
AND p.`id_product` IS NOT NULL AND p.`id_product` IS NOT NULL
ORDER BY c.`position` ORDER BY c.`position`
@ -189,28 +189,51 @@ class AdminAntWp extends AdminTab
if($row['ean13']!='' && isset($products[$row['ean13']])){ if($row['ean13']!='' && isset($products[$row['ean13']])){
$products[$row['ean13']] = array_merge($products[$row['ean13']], $row); $products[$row['ean13']] = array_merge($products[$row['ean13']], $row);
$product_found++; $product_found++;
$ids[] = (int)$row['id_product'];
} elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){ } elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
$products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row); $products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row);
$product_found++; $product_found++;
$ids[] = (int)$row['id_product'];
} }
if(!in_array((int)$row['id_product'],$ids)){ if(!in_array((int)$row['id_product'],$ids)){
$ids[] = (int)$row['id_product']; $ids[] = (int)$row['id_product'];
} }
} }
$new_products = count($products) - $product_found; $new_products = count($products) - $product_found;
if(!empty($ids)){ if(!empty($ids)){
foreach (Db::getInstance()->executeS(' foreach (Db::getInstance()->executeS('
SELECT p.`ean13`, p.`supplier_reference`, pl.* SELECT p.`ean13`, p.`supplier_reference`, pl.*
FROM ps_product_lang pl FROM '._DB_PREFIX_.'product p
LEFT JOIN ps_product p ON (pl.`id_product` = p.`id_product`) LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.`id_product` = p.`id_product`)
WHERE pl.`id_product` IN ('.implode(',',$ids).') WHERE p.`id_product` IN ('.implode(',',$ids).')
AND (pl.id_lang = 2 OR pl.id_lang = 3) AND (pl.id_lang = 2 OR pl.id_lang = 3)
ORDER BY pl.`id_product` ORDER BY p.`id_product`
') as $row) { ') as $row) {
if($row['ean13']!='' && isset($products[$row['ean13']])){ if($row['ean13']!='' && isset($products[(int)$row['ean13']])){
if(!isset($products[$row['ean13']]['lang'])){
$products[$row['ean13']]['lang'] = array();
}
if(!isset($products[$row['ean13']]['lang'][(int)$row['id_lang']])){
$products[$row['ean13']]['lang'][(int)$row['id_lang']] = $row;
}
} elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
if(!isset($products[$row['supplier_reference']]['lang'])){
$products[$row['supplier_reference']]['lang'] = array();
}
if(!isset($products[$row['supplier_reference']]['lang'][(int)$row['id_lang']])){
$products[$row['supplier_reference']]['lang'][(int)$row['id_lang']] = $row;
}
}
}
foreach (Db::getInstance()->executeS('
SELECT at.`ean13`, p.`supplier_reference`, pl.*
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.`id_product` = p.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_attribute` at ON (at.`id_product` = p.`id_product`)
WHERE p.`id_product` IN ('.implode(',',$ids).')
AND (pl.id_lang = 2 OR pl.id_lang = 3)
ORDER BY p.`id_product`
') as $row) {
if($row['ean13']!='' && isset($products[(int)$row['ean13']])){
if(!isset($products[$row['ean13']]['lang'])){ if(!isset($products[$row['ean13']]['lang'])){
$products[$row['ean13']]['lang'] = array(); $products[$row['ean13']]['lang'] = array();
} }

File diff suppressed because one or more lines are too long

View File

@ -66,6 +66,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
const FORMAT_CURRENCY_USD_SIMPLE = '"$"#,##0.00_-'; const FORMAT_CURRENCY_USD_SIMPLE = '"$"#,##0.00_-';
const FORMAT_CURRENCY_USD = '$#,##0_-'; const FORMAT_CURRENCY_USD = '$#,##0_-';
const FORMAT_CURRENCY_EUR_SIMPLE = '[$EUR ]#,##0.00_-'; const FORMAT_CURRENCY_EUR_SIMPLE = '[$EUR ]#,##0.00_-';
const FORMAT_CURRENCY_EUR = '#.00 [$€];-#.00 [$€]';
/** /**
* Excel built-in number formats * Excel built-in number formats
@ -264,7 +265,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
// 40: "#,##0.00_);[Red](#,##0.00)" // 40: "#,##0.00_);[Red](#,##0.00)"
// 47: "mm:ss.0" // 47: "mm:ss.0"
// KOR fmt 55: "yyyy/mm/dd" // KOR fmt 55: "yyyy/mm/dd"
// Built-in format codes // Built-in format codes
if (is_null(self::$builtInFormats)) { if (is_null(self::$builtInFormats)) {
self::$builtInFormats = array(); self::$builtInFormats = array();