From a6ebb26af0394b6f8677004f9586a01e0ac46462 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Mon, 30 Oct 2017 15:45:23 +0100 Subject: [PATCH] fix when product not found --- modules/ant_wp/GenerateWp.php | 271 +++++++++++++++++++++------------- 1 file changed, 171 insertions(+), 100 deletions(-) diff --git a/modules/ant_wp/GenerateWp.php b/modules/ant_wp/GenerateWp.php index 838e9775..891fb32c 100644 --- a/modules/ant_wp/GenerateWp.php +++ b/modules/ant_wp/GenerateWp.php @@ -192,86 +192,87 @@ class GenerateWp } $i++; foreach ($params['lines'] as $key => $row) { - $id_categories = array(); - foreach(Db::getInstance()->ExecuteS(' - SELECT `id_category` - FROM `'._DB_PREFIX_.'category_product` - WHERE `id_product` = '.(int) $row['id_product'].' - ') as $cat) { - $id_categories[] = (int) $cat['id_category']; - } - sort($id_categories); - - $categories_title = array(2 => array(0 => '', 1 => '', 2 => ''), 3 => array(0 => '', 1 => '', 2 => '')); - foreach ($id_categories as $key => $id_category) { - foreach (Db::getInstance()->executeS(' - SELECT `name`,`id_lang` - FROM `'._DB_PREFIX_.'category_lang` - WHERE `id_category` = '.(int) $id_category.' - AND (`id_lang` = 2 OR `id_lang` = 3) - ') as $title) { - $categories_title[$title['id_lang']][$key] = $title['name']; + if(isset($row['id_product'])){ + $id_categories = array(); + foreach(Db::getInstance()->ExecuteS(' + SELECT `id_category` + FROM `'._DB_PREFIX_.'category_product` + WHERE `id_product` = '.(int) $row['id_product'].' + ') as $cat) { + $id_categories[] = (int) $cat['id_category']; } - } + sort($id_categories); - $images = array(); - foreach(Db::getInstance()->ExecuteS(' - SELECT i.`id_image`, l.`legend` - FROM `'._DB_PREFIX_.'image` i - LEFT JOIN `'._DB_PREFIX_.'image_lang` l ON l.`id_image` = i.`id_image` - WHERE l.`id_lang` = 2 - AND i.`id_product` = '.(int) $row['id_product'].' - ORDER BY i.`position` - ') as $img) { - $link_image = str_split($img['id_image']); - $images[] = 'https://static.bebeboutik.com/img/p/'.implode('/', $link_image) .'/'. $img['id_image'].'.jpg'; - } - $price = Product::getPriceStatic($row['id_product'],TRUE, NULL, 2, NULL, FALSE, FALSE); - $price2 = Product::getPriceStatic($row['id_product'],TRUE, NULL, 2); + $categories_title = array(2 => array(0 => '', 1 => '', 2 => ''), 3 => array(0 => '', 1 => '', 2 => '')); + foreach ($id_categories as $key => $id_category) { + foreach (Db::getInstance()->executeS(' + SELECT `name`,`id_lang` + FROM `'._DB_PREFIX_.'category_lang` + WHERE `id_category` = '.(int) $id_category.' + AND (`id_lang` = 2 OR `id_lang` = 3) + ') as $title) { + $categories_title[$title['id_lang']][$key] = $title['name']; + } + } - $this->objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$i, (String)$row['ean']) - ->setCellValue('C'.$i, $row['supplier_reference']) - ->setCellValue('D'.$i, '=IF(AND(E'.$i.'="";F'.$i.'="";G'.$i.'="");"";E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')') - ->setCellValue('E'.$i, '') - ->setCellValue('F'.$i, '') - ->setCellValue('G'.$i, '') - ->setCellValue('H'.$i, $row['name_ha']) - ->setCellValue('I'.$i, $row['lang'][2]['name']) - ->setCellValue('J'.$i, '=LEN(D'.$i.')') - ->setCellValue('K'.$i, (int)$row['position']) - ->setCellValue('L'.$i, $categories_title[2][0]) - ->setCellValue('M'.$i, $categories_title[2][1]) - ->setCellValue('N'.$i, $categories_title[2][2]) - ->setCellValue('O'.$i, count($images)) - ->setCellValue('P'.$i, '') - ->setCellValue('Q'.$i, '=AM1 & "-" & P'.$i.' & "-" & LEFT(C'.$i.';9)') - ->setCellValue('R'.$i, '=IF(Q'.$i.'="";"";LEN(Q'.$i.'))') - ->setCellValue('S'.$i, $row['lang'][2]['description_short']) - ->setCellValue('T'.$i, $row['lang'][2]['description']) - ->setCellValue('U'.$i, $row['lang'][2]['description_more']) - ->setCellValue('V'.$i, $row['lang'][2]['videos']) - ->setCellValue('W'.$i, $row['lang'][2]['description_delivery']) - ->setCellValue('X'.$i, $row['weight']) - ->setCellValue('Y'.$i, '') - ->setCellValue('Z'.$i, '') - ->setCellValue('AA'.$i, $row['quantity']) - ->setCellValue('AB'.$i, $row['height']) - ->setCellValue('AC'.$i, $row['id_tax_rules_group']) - ->setCellValue('AD'.$i, $row['ppc']) - ->setCellValue('AE'.$i, '') - ->setCellValue('AF'.$i, $row['prix_ha']) - ->setCellValue('AG'.$i, Tools::ps_round($row['wholesale_price'], 2)) - ->setCellValue('AH'.$i, '=IF(AG'.$i.'="";"";IF((AF'.$i.'-AG'.$i.')>0;"ATTENTION";IF((AF'.$i.'-AG'.$i.')<0;"COOL";IF((AF'.$i.'-AG'.$i.')=0;"OK";""))))') - ->setCellValue('AI'.$i, '=IF(AF'.$i.'="";"";(AF'.$i.'*1,85))') - ->setCellValue('AJ'.$i, $price2) - ->setCellValue('AK'.$i, '=IF(AND(AD'.$i.'="";AI'.$i.'="");"";ROUND((1-AI'.$i.'/AD'.$i.')*100;4))') - ->setCellValue('AL'.$i, '=IF(AND(AF'.$i.'="";AI'.$i.'="");"";1-AF'.$i.'/(AI'.$i.'/1,2))') - ->setCellValue('AM'.$i, '=IF(O'.$i.'="";"";IF(O'.$i.'=1;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg";IF(O'.$i.'=2;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg";IF(O'.$i.'=3;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg";IF(O'.$i.'=4;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg";IF(O'.$i.'='.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg";IF(O'.$i.'=6;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg";IF(O'.$i.'=7;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg";IF(O'.$i.'=8;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg";IF(O'.$i.'=9;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg";IF(O'.$i.'=10;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg";IF(O'.$i.'=11;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg";IF(O'.$i.'=12;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg";IF(O'.$i.'=13;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg";IF(O'.$i.'=14;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg";IF(O'.$i.'=1'.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-14.jpg"))))))))))))))))') - ->setCellValue('AN'.$i, implode(', ', $images)) - ->setCellValue('AO'.$i, '=AA'.$i.'*AF'.$i) - ->setCellValue('AP'.$i, isset($row['nc8'])?$row['nc8']:"") - ->setCellValue('AQ'.$i, isset($row['id_country'])?$row['id_country']:"") - ->setCellValue('AR'.$i, ''); + $images = array(); + foreach(Db::getInstance()->ExecuteS(' + SELECT i.`id_image`, l.`legend` + FROM `'._DB_PREFIX_.'image` i + LEFT JOIN `'._DB_PREFIX_.'image_lang` l ON l.`id_image` = i.`id_image` + WHERE l.`id_lang` = 2 + AND i.`id_product` = '.(int) $row['id_product'].' + ORDER BY i.`position` + ') as $img) { + $link_image = str_split($img['id_image']); + $images[] = 'https://static.bebeboutik.com/img/p/'.implode('/', $link_image) .'/'. $img['id_image'].'.jpg'; + } + $price = Product::getPriceStatic($row['id_product'],TRUE, NULL, 2, NULL, FALSE, FALSE); + $price2 = Product::getPriceStatic($row['id_product'],TRUE, NULL, 2); + + $this->objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$i, (String)$row['ean']) + ->setCellValue('C'.$i, $row['supplier_reference']) + ->setCellValue('D'.$i, '=IF(AND(E'.$i.'="";F'.$i.'="";G'.$i.'="");"";E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')') + ->setCellValue('E'.$i, '') + ->setCellValue('F'.$i, '') + ->setCellValue('G'.$i, '') + ->setCellValue('H'.$i, $row['name_ha']) + ->setCellValue('I'.$i, $row['lang'][2]['name']) + ->setCellValue('J'.$i, '=LEN(D'.$i.')') + ->setCellValue('K'.$i, (int)$row['position']) + ->setCellValue('L'.$i, $categories_title[2][0]) + ->setCellValue('M'.$i, $categories_title[2][1]) + ->setCellValue('N'.$i, $categories_title[2][2]) + ->setCellValue('O'.$i, count($images)) + ->setCellValue('P'.$i, '') + ->setCellValue('Q'.$i, '=AM1 & "-" & P'.$i.' & "-" & LEFT(C'.$i.';9)') + ->setCellValue('R'.$i, '=IF(Q'.$i.'="";"";LEN(Q'.$i.'))') + ->setCellValue('S'.$i, $row['lang'][2]['description_short']) + ->setCellValue('T'.$i, $row['lang'][2]['description']) + ->setCellValue('U'.$i, $row['lang'][2]['description_more']) + ->setCellValue('V'.$i, $row['lang'][2]['videos']) + ->setCellValue('W'.$i, $row['lang'][2]['description_delivery']) + ->setCellValue('X'.$i, $row['weight']) + ->setCellValue('Y'.$i, '') + ->setCellValue('Z'.$i, '') + ->setCellValue('AA'.$i, $row['quantity']) + ->setCellValue('AB'.$i, $row['height']) + ->setCellValue('AC'.$i, $row['id_tax_rules_group']) + ->setCellValue('AD'.$i, $row['ppc']) + ->setCellValue('AE'.$i, '') + ->setCellValue('AF'.$i, $row['prix_ha']) + ->setCellValue('AG'.$i, Tools::ps_round($row['wholesale_price'], 2)) + ->setCellValue('AH'.$i, '=IF(AG'.$i.'="";"";IF((AF'.$i.'-AG'.$i.')>0;"ATTENTION";IF((AF'.$i.'-AG'.$i.')<0;"COOL";IF((AF'.$i.'-AG'.$i.')=0;"OK";""))))') + ->setCellValue('AI'.$i, '=IF(AF'.$i.'="";"";(AF'.$i.'*1,85))') + ->setCellValue('AJ'.$i, $price2) + ->setCellValue('AK'.$i, '=IF(AND(AD'.$i.'="";AI'.$i.'="");"";ROUND((1-AI'.$i.'/AD'.$i.')*100;4))') + ->setCellValue('AL'.$i, '=IF(AND(AF'.$i.'="";AI'.$i.'="");"";1-AF'.$i.'/(AI'.$i.'/1,2))') + ->setCellValue('AM'.$i, '=IF(O'.$i.'="";"";IF(O'.$i.'=1;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg";IF(O'.$i.'=2;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg";IF(O'.$i.'=3;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg";IF(O'.$i.'=4;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg";IF(O'.$i.'='.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg";IF(O'.$i.'=6;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg";IF(O'.$i.'=7;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg";IF(O'.$i.'=8;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg";IF(O'.$i.'=9;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg";IF(O'.$i.'=10;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg";IF(O'.$i.'=11;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg";IF(O'.$i.'=12;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg";IF(O'.$i.'=13;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg";IF(O'.$i.'=14;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg";IF(O'.$i.'=1'.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-14.jpg"))))))))))))))))') + ->setCellValue('AN'.$i, implode(', ', $images)) + ->setCellValue('AO'.$i, '=AA'.$i.'*AF'.$i) + ->setCellValue('AP'.$i, isset($row['nc8'])?$row['nc8']:"") + ->setCellValue('AQ'.$i, isset($row['id_country'])?$row['id_country']:"") + ->setCellValue('AR'.$i, ''); $this->objPHPExcel->setActiveSheetIndex(0)->getStyle('B'.$i.':AR'.$i.'')->applyFromArray($borders_style); $this->objPHPExcel->setActiveSheetIndex(1)->setCellValue('B'.$i, (String)$row['ean']) @@ -287,6 +288,66 @@ class GenerateWp ->setCellValue('L'.$i, $row['lang'][3]['videos']) ->setCellValue('M'.$i, $row['lang'][3]['description_delivery']); $this->objPHPExcel->setActiveSheetIndex(1)->getStyle('B'.$i.':M'.$i.'')->applyFromArray($borders_style); + } else { + $this->objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$i, (String)$row['ean']) + ->setCellValue('C'.$i, $row['supplier_ref']) + ->setCellValue('D'.$i, '=IF(AND(E'.$i.'="";F'.$i.'="";G'.$i.'="");"";E'.$i.'&" "&F'.$i.'&" - "&G'.$i.')') + ->setCellValue('E'.$i, '') + ->setCellValue('F'.$i, '') + ->setCellValue('G'.$i, '') + ->setCellValue('H'.$i, '') + ->setCellValue('I'.$i, $row['name_ha']) + ->setCellValue('J'.$i, '=LEN(D'.$i.')') + ->setCellValue('K'.$i, '') + ->setCellValue('L'.$i, '') + ->setCellValue('M'.$i, '') + ->setCellValue('N'.$i, '') + ->setCellValue('O'.$i, '') + ->setCellValue('P'.$i, '') + ->setCellValue('Q'.$i, '=AM1 & "-" & P'.$i.' & "-" & LEFT(C'.$i.';9)') + ->setCellValue('R'.$i, '=IF(Q'.$i.'="";"";LEN(Q'.$i.'))') + ->setCellValue('S'.$i, '') + ->setCellValue('T'.$i, '') + ->setCellValue('U'.$i, '') + ->setCellValue('V'.$i, '') + ->setCellValue('W'.$i, '') + ->setCellValue('X'.$i, '') + ->setCellValue('Y'.$i, '') + ->setCellValue('Z'.$i, '') + ->setCellValue('AA'.$i, $row['quantity']) + ->setCellValue('AB'.$i, '') + ->setCellValue('AC'.$i, '') + ->setCellValue('AD'.$i, $row['ppc']) + ->setCellValue('AE'.$i, '') + ->setCellValue('AF'.$i, $row['prix_ha']) + ->setCellValue('AG'.$i, '') + ->setCellValue('AH'.$i, '=IF(AG'.$i.'="";"";IF((AF'.$i.'-AG'.$i.')>0;"ATTENTION";IF((AF'.$i.'-AG'.$i.')<0;"COOL";IF((AF'.$i.'-AG'.$i.')=0;"OK";""))))') + ->setCellValue('AI'.$i, '=IF(AF'.$i.'="";"";(AF'.$i.'*1,85))') + ->setCellValue('AJ'.$i, '') + ->setCellValue('AK'.$i, '=IF(AND(AD'.$i.'="";AI'.$i.'="");"";ROUND((1-AI'.$i.'/AD'.$i.')*100;4))') + ->setCellValue('AL'.$i, '=IF(AND(AF'.$i.'="";AI'.$i.'="");"";1-AF'.$i.'/(AI'.$i.'/1,2))') + ->setCellValue('AM'.$i, '=IF(O'.$i.'="";"";IF(O'.$i.'=1;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg";IF(O'.$i.'=2;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg";IF(O'.$i.'=3;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg";IF(O'.$i.'=4;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg";IF(O'.$i.'='.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg";IF(O'.$i.'=6;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg";IF(O'.$i.'=7;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg";IF(O'.$i.'=8;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg";IF(O'.$i.'=9;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg";IF(O'.$i.'=10;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg";IF(O'.$i.'=11;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg";IF(O'.$i.'=12;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg";IF(O'.$i.'=13;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg";IF(O'.$i.'=14;"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg";IF(O'.$i.'=1'.$i.';"https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&".jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-1.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-2.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-3.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-4.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-5.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-6.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-7.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-8.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-9.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-10.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-11.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-12.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-13.jpg,https://static.bebeboutik.com/img_import/"&$AM$1&"/"&C'.$i.'&"-14.jpg"))))))))))))))))') + ->setCellValue('AN'.$i, '') + ->setCellValue('AO'.$i, '=AA'.$i.'*AF'.$i) + ->setCellValue('AP'.$i, '') + ->setCellValue('AQ'.$i, '') + ->setCellValue('AR'.$i, ''); + $this->objPHPExcel->setActiveSheetIndex(0)->getStyle('B'.$i.':AR'.$i.'')->applyFromArray($borders_style); + + $this->objPHPExcel->setActiveSheetIndex(1)->setCellValue('B'.$i, (String)$row['ean']) + ->setCellValue('C'.$i, $row['supplier_ref']) + ->setCellValue('D'.$i, '') + ->setCellValue('E'.$i, '') + ->setCellValue('F'.$i, '') + ->setCellValue('G'.$i, '') + ->setCellValue('H'.$i, '') + ->setCellValue('I'.$i, '') + ->setCellValue('J'.$i, '') + ->setCellValue('K'.$i, '') + ->setCellValue('L'.$i, '') + ->setCellValue('M'.$i, ''); + $this->objPHPExcel->setActiveSheetIndex(1)->getStyle('B'.$i.':M'.$i.'')->applyFromArray($borders_style); + } $i++; } $this->objPHPExcel->setActiveSheetIndex(0); @@ -302,6 +363,7 @@ if(isset($_FILES['csvfile']) && $_FILES['csvfile']['name'] != '') { $f = fopen($_FILES['csvfile']['tmp_name'], 'r'); fgetcsv($f, 0, ';'); $products = array(); + $product_info = array(); $refs = array(); $eans = array(); while($line = fgetcsv($f, 0, ';')) { @@ -351,35 +413,44 @@ if(isset($_FILES['csvfile']) && $_FILES['csvfile']['name'] != '') { '.(!empty($refs)?' OR p.`supplier_reference` IN ("'.implode('","',$refs).'")':'').' ORDER BY c.`position` ') as $row) { - if(!isset($product_info[(int)$row['id_product']])){ + if($row['ean13']!='' && isset($products[$row['ean13']])){ + $products[$row['ean13']] = array_merge($products[$row['ean13']], $row); + $product_found++; + } elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){ + $products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row); + $product_found++; + } + $ids[] = (int)$row['id_product']; + } + $new_products = count($ids) - $product_found; + if(!empty($ids)){ + foreach (Db::getInstance()->executeS(' + SELECT p.`ean13`, p.`supplier_reference`, pl.* + FROM ps_product_lang pl + LEFT ps_product p ON (pl.`id_product` = p.`id_product`) + WHERE pl.`id_product` IN ('.implode(',',$ids).') + AND (pl.id_lang = 2 OR pl.id_lang = 3) + ORDER BY pl.`id_product` + ') as $row) { if($row['ean13']!='' && isset($products[$row['ean13']])){ - $product_info[(int)$row['id_product']] = array_merge($products[$row['ean13']], $row); - $product_found++; + 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']])){ - $product_info[(int)$row['id_product']] = array_merge($products[$row['supplier_reference']], $row); - $product_found++; + 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; + } } - $ids[] = (int)$row['id_product']; - } - } - $new_products = count($products) - $product_found; - - foreach (Db::getInstance()->executeS(' - SELECT pl.* - FROM ps_product_lang pl - WHERE pl.`id_product` IN ('.implode(',',$ids).') - AND (pl.id_lang = 2 OR pl.id_lang = 3) - ORDER BY pl.`id_product` - ') as $row) { - if(!isset($product_info[$row['id_product']]['lang'])){ - $product_info[$row['id_product']]['lang'] = array(); - } - if(!isset($product_info[$row['id_product']]['lang'][(int)$row['id_lang']])){ - $product_info[$row['id_product']]['lang'][(int)$row['id_lang']] = $row; } } - $params['lines'] = $product_info; + $params['lines'] = $products; if(!empty($params['lines'])){ $wp = new GenerateWp();