Merge branch 'develop' of git@gitlab.antadis.net:dev-antadis/bebeboutik.git into develop
This commit is contained in:
commit
411c795497
@ -5,15 +5,20 @@ include_once(_PS_ROOT_DIR_.'/modules/ant_wp/GenerateWp.php');
|
|||||||
require_once _PS_PHPEXCEL_DIR_.'Classes/PHPExcel.php';
|
require_once _PS_PHPEXCEL_DIR_.'Classes/PHPExcel.php';
|
||||||
require_once _PS_PHPEXCEL_DIR_.'Classes/PHPExcel/IOFactory.php';
|
require_once _PS_PHPEXCEL_DIR_.'Classes/PHPExcel/IOFactory.php';
|
||||||
|
|
||||||
|
ini_set('memory_limit', '8G');
|
||||||
|
ini_set('max_execution_time', 300);
|
||||||
class AdminAntWp extends AdminTab
|
class AdminAntWp extends AdminTab
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const DUPLICATED_EANS = 'duplicated_ean';
|
||||||
|
const DUPLICATED_REFS = 'duplicated_refs';
|
||||||
protected $_html;
|
protected $_html;
|
||||||
public $module_name;
|
public $module_name;
|
||||||
public $config_tab;
|
public $config_tab;
|
||||||
public $controller;
|
public $controller;
|
||||||
public $helperForm;
|
public $helperForm;
|
||||||
public $_object;
|
public $_object;
|
||||||
|
public $report;
|
||||||
|
|
||||||
public function __construct($config_tab = true)
|
public function __construct($config_tab = true)
|
||||||
{
|
{
|
||||||
@ -26,6 +31,9 @@ class AdminAntWp extends AdminTab
|
|||||||
$this->controller = 'AdminAntWp';
|
$this->controller = 'AdminAntWp';
|
||||||
}
|
}
|
||||||
$this->helperForm = new HelperFormBootstrap();
|
$this->helperForm = new HelperFormBootstrap();
|
||||||
|
$this->report = array();
|
||||||
|
$this->report[self::DUPLICATED_EANS] = array();
|
||||||
|
$this->report[self::DUPLICATED_REFS] = array();
|
||||||
// $this->helperForm->_select2 = true;
|
// $this->helperForm->_select2 = true;
|
||||||
// $this->helperForm->_inputSwitch = true;
|
// $this->helperForm->_inputSwitch = true;
|
||||||
}
|
}
|
||||||
@ -101,6 +109,8 @@ class AdminAntWp extends AdminTab
|
|||||||
fgetcsv($f, 0, ';');
|
fgetcsv($f, 0, ';');
|
||||||
$products = array();
|
$products = array();
|
||||||
$product_info = array();
|
$product_info = array();
|
||||||
|
$timer_table = array();
|
||||||
|
$callStartTime = microtime(true);
|
||||||
$refs = array();
|
$refs = array();
|
||||||
$eans = array();
|
$eans = array();
|
||||||
while($line = fgetcsv($f, 0, ';')) {
|
while($line = fgetcsv($f, 0, ';')) {
|
||||||
@ -109,191 +119,215 @@ class AdminAntWp extends AdminTab
|
|||||||
}
|
}
|
||||||
if($line[0] != '') {
|
if($line[0] != '') {
|
||||||
$ean = trim($line[0]);
|
$ean = trim($line[0]);
|
||||||
$products[$ean] = array(
|
if(!isset($products[$ean])){
|
||||||
'ean' => $ean,
|
$products[$ean] = array(
|
||||||
'supplier_ref' => trim((String)utf8_encode($line[1])),
|
'ean' => $ean,
|
||||||
'name_ha' => trim((String)utf8_encode($line[2])),
|
'supplier_ref' => trim((String)utf8_encode($line[1])),
|
||||||
'quantity' => trim($line[3]),
|
'name_ha' => trim((String)utf8_encode($line[2])),
|
||||||
'ppc' => trim((float)$line[4]),
|
'quantity' => trim($line[3]),
|
||||||
'prix_ha' => trim((float)$line[5]),
|
'ppc' => trim((float)$line[4]),
|
||||||
'name_attribute_ha' => trim((String)$line[6])
|
'prix_ha' => trim((float)$line[5]),
|
||||||
);
|
'name_attribute_ha' => trim((String)$line[6])
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$this->report[self::DUPLICATED_EANS][] = $ean;
|
||||||
|
}
|
||||||
$eans[] = $ean;
|
$eans[] = $ean;
|
||||||
} else {
|
} else {
|
||||||
$ref = trim((String)utf8_encode($line[1]));
|
$ref = trim((String)utf8_encode($line[1]));
|
||||||
$products[$ref] = array(
|
if(!isset($products[$ref])) {
|
||||||
'ean' => trim($line[0]),
|
$products[$ref] = array(
|
||||||
'supplier_ref' => $ref,
|
'ean' => trim($line[0]),
|
||||||
'name_ha' => trim((String)utf8_encode($line[2])),
|
'supplier_ref' => $ref,
|
||||||
'quantity' => trim($line[3]),
|
'name_ha' => trim((String)utf8_encode($line[2])),
|
||||||
'ppc' => trim((float)$line[4]),
|
'quantity' => trim($line[3]),
|
||||||
'prix_ha' => trim((float)$line[5]),
|
'ppc' => trim((float)$line[4]),
|
||||||
'name_attribute_ha' => trim((String)utf8_encode($line[6]))
|
'prix_ha' => trim((float)$line[5]),
|
||||||
);
|
'name_attribute_ha' => trim((String)utf8_encode($line[6]))
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$this->report[self::DUPLICATED_REFS][] = $ref;
|
||||||
|
}
|
||||||
$refs[] = $ref;
|
$refs[] = $ref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$product_info = array();
|
$product_info = array();
|
||||||
$product_found = 0;
|
$product_found = 0;
|
||||||
$ids = array();
|
$ids = array();
|
||||||
$exclude_ids = $this->getBraderieProducts();
|
$exclude_ids = $this->getBraderieProducts();
|
||||||
foreach (Db::getInstance()->executeS('
|
$timer_table[] = 'Excluded products gathered at '.(microtime(true)-$callStartTime);
|
||||||
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, p.`ean13`, p.`price`, p.`wholesale_price`,
|
if(count($eans) > 0) {
|
||||||
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`
|
$sql = '
|
||||||
FROM
|
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, p.`ean13`, p.`price`, p.`wholesale_price`,
|
||||||
`'._DB_PREFIX_.'product` p
|
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`
|
||||||
INNER JOIN (
|
FROM
|
||||||
SELECT date_add, max(id_product) as maxid
|
`' . _DB_PREFIX_ . 'product` p
|
||||||
FROM `'._DB_PREFIX_.'product`
|
INNER JOIN (
|
||||||
WHERE id_product NOT IN ('.implode(',',$exclude_ids).')
|
SELECT date_add, max(id_product) as maxid
|
||||||
GROUP BY ean13
|
FROM `' . _DB_PREFIX_ . 'product`
|
||||||
) as b
|
WHERE id_product NOT IN (' . implode(',', $exclude_ids) . ')
|
||||||
ON p.`id_product` = b.maxid
|
GROUP BY ean13
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` c
|
) as b
|
||||||
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
|
ON p.`id_product` = b.maxid
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_customs` cu
|
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c
|
||||||
ON (cu.`id_product` = p.`id_product`)
|
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
|
||||||
WHERE p.`ean13` IN ("'.implode('","',$eans).'")
|
LEFT JOIN `' . _DB_PREFIX_ . 'product_customs` cu
|
||||||
AND p.`id_product` IS NOT NULL
|
ON (cu.`id_product` = p.`id_product`)
|
||||||
ORDER BY c.`position`
|
WHERE p.`ean13` IN ("' . implode('","', $eans) . '")
|
||||||
') as $row) {
|
AND p.`id_product` IS NOT NULL
|
||||||
if($row['ean13']!='' && isset($products[$row['ean13']])){
|
ORDER BY c.`position`
|
||||||
$products[$row['ean13']] = array_merge($products[$row['ean13']], $row);
|
';
|
||||||
$product_found++;
|
$result = Db::getInstance()->executeS($sql);
|
||||||
$ids[] = (int)$row['id_product'];
|
|
||||||
}
|
|
||||||
// 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'];
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Db::getInstance()->executeS('
|
foreach ($result as $row) {
|
||||||
|
if($row['ean13'] == '8427077902761'){
|
||||||
|
$timer_table[] = json_encode($row);
|
||||||
|
}
|
||||||
|
if ($row['ean13'] != '' && isset($products[$row['ean13']])) {
|
||||||
|
$products[$row['ean13']] = array_merge($products[$row['ean13']], $row);
|
||||||
|
$product_found++;
|
||||||
|
$ids[] = (int)$row['id_product'];
|
||||||
|
}
|
||||||
|
// 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'];
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$timer_table[] = 'Ean product gathered at '.(microtime(true)-$callStartTime);
|
||||||
|
if(count($refs)> 0) {
|
||||||
|
foreach (Db::getInstance()->executeS('
|
||||||
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, p.`ean13`, p.`price`, p.`wholesale_price`,
|
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, p.`ean13`, p.`price`, p.`wholesale_price`,
|
||||||
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`
|
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`
|
||||||
FROM
|
FROM
|
||||||
`'._DB_PREFIX_.'product` p
|
`' . _DB_PREFIX_ . 'product` p
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT date_add, max(id_product) as maxid
|
SELECT date_add, max(id_product) as maxid
|
||||||
FROM `'._DB_PREFIX_.'product`
|
FROM `' . _DB_PREFIX_ . 'product`
|
||||||
WHERE id_product NOT IN ('.implode(',',$exclude_ids).')
|
WHERE id_product NOT IN (' . implode(',', $exclude_ids) . ')
|
||||||
GROUP BY supplier_reference
|
GROUP BY supplier_reference
|
||||||
) as b
|
) as b
|
||||||
ON p.`id_product` = b.maxid
|
ON p.`id_product` = b.maxid
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` c
|
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c
|
||||||
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
|
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_customs` cu
|
LEFT JOIN `' . _DB_PREFIX_ . 'product_customs` cu
|
||||||
ON (cu.`id_product` = p.`id_product`)
|
ON (cu.`id_product` = p.`id_product`)
|
||||||
WHERE p.`supplier_reference` IN ("'.implode('","',$refs).'")
|
WHERE p.`supplier_reference` IN ("' . implode('","', $refs) . '")
|
||||||
AND p.`id_product` IS NOT NULL
|
AND p.`id_product` IS NOT NULL
|
||||||
ORDER BY c.`position`
|
ORDER BY c.`position`
|
||||||
') as $row) {
|
') as $row) {
|
||||||
// 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'];
|
// $ids[] = (int)$row['id_product'];
|
||||||
// } else
|
// } else
|
||||||
if($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
|
if ($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'];
|
$ids[] = (int)$row['id_product'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$timer_table[] = 'Ref product gathered at '.(microtime(true)-$callStartTime);
|
||||||
foreach (Db::getInstance()->executeS('
|
if(count($eans) > 0) {
|
||||||
|
foreach (Db::getInstance()->executeS('
|
||||||
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, b.`id_product_attribute`, b.`ean13`, b.`supplier_reference` as at_ref, p.`price`, p.`wholesale_price`,
|
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, b.`id_product_attribute`, b.`ean13`, b.`supplier_reference` as at_ref, p.`price`, p.`wholesale_price`,
|
||||||
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`,
|
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`,
|
||||||
al.`name` as attribute_name
|
al.`name` as attribute_name
|
||||||
FROM
|
FROM
|
||||||
`'._DB_PREFIX_.'product` p
|
`' . _DB_PREFIX_ . 'product` p
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT max(id_product) as maxid, ean13, `supplier_reference`, `id_product_attribute`
|
SELECT max(id_product) as maxid, ean13, `supplier_reference`, `id_product_attribute`
|
||||||
FROM `'._DB_PREFIX_.'product_attribute`
|
FROM `' . _DB_PREFIX_ . 'product_attribute`
|
||||||
WHERE id_product NOT IN ('.implode(',',$exclude_ids).')
|
WHERE id_product NOT IN (' . implode(',', $exclude_ids) . ')
|
||||||
GROUP BY ean13
|
GROUP BY ean13
|
||||||
) as b
|
) as b
|
||||||
ON p.`id_product`= b.maxid
|
ON p.`id_product`= b.maxid
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` c
|
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c
|
||||||
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
|
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_customs` cu
|
LEFT JOIN `' . _DB_PREFIX_ . 'product_customs` cu
|
||||||
ON (cu.`id_product` = p.`id_product`)
|
ON (cu.`id_product` = p.`id_product`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` ac
|
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` ac
|
||||||
ON (ac.`id_product_attribute` = b.`id_product_attribute`)
|
ON (ac.`id_product_attribute` = b.`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_lang` = 2)
|
ON (al.`id_attribute` = ac.`id_attribute` AND al.`id_lang` = 2)
|
||||||
WHERE b.`ean13` IN ("'.implode('","',$eans).'")
|
WHERE b.`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`
|
||||||
') as $row) {
|
') as $row) {
|
||||||
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++;
|
||||||
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'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
|
||||||
|
// $products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row);
|
||||||
|
// $product_found++;
|
||||||
|
// if(!in_array((int)$row['id_product'],$ids)){
|
||||||
|
// $ids[] = (int)$row['id_product'];
|
||||||
|
// }
|
||||||
|
// } elseif($row['at_ref']!='' && isset($products[$row['at_ref']])){
|
||||||
|
// $products[$row['at_ref']] = array_merge($products[$row['at_ref']], $row);
|
||||||
|
// $product_found++;
|
||||||
|
// if(!in_array((int)$row['id_product'],$ids)){
|
||||||
|
// $ids[] = (int)$row['id_product'];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
// elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
|
|
||||||
// $products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row);
|
|
||||||
// $product_found++;
|
|
||||||
// if(!in_array((int)$row['id_product'],$ids)){
|
|
||||||
// $ids[] = (int)$row['id_product'];
|
|
||||||
// }
|
|
||||||
// } elseif($row['at_ref']!='' && isset($products[$row['at_ref']])){
|
|
||||||
// $products[$row['at_ref']] = array_merge($products[$row['at_ref']], $row);
|
|
||||||
// $product_found++;
|
|
||||||
// if(!in_array((int)$row['id_product'],$ids)){
|
|
||||||
// $ids[] = (int)$row['id_product'];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
foreach (Db::getInstance()->executeS('
|
$timer_table[] = 'Ean product attr gathered at '.(microtime(true)-$callStartTime);
|
||||||
|
if(count($refs) > 0) {
|
||||||
|
foreach (Db::getInstance()->executeS('
|
||||||
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`,b.`id_product_attribute`, b.`ean13`, b.`supplier_reference` as at_ref, p.`price`, p.`wholesale_price`,
|
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`,b.`id_product_attribute`, b.`ean13`, b.`supplier_reference` as at_ref, p.`price`, p.`wholesale_price`,
|
||||||
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`,
|
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`,
|
||||||
al.`name` as attribute_name
|
al.`name` as attribute_name
|
||||||
FROM
|
FROM
|
||||||
`'._DB_PREFIX_.'product` p
|
`' . _DB_PREFIX_ . 'product` p
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT max(id_product) as maxid, ean13, `supplier_reference`, `id_product_attribute`
|
SELECT max(id_product) as maxid, ean13, `supplier_reference`, `id_product_attribute`
|
||||||
FROM `'._DB_PREFIX_.'product_attribute`
|
FROM `' . _DB_PREFIX_ . 'product_attribute`
|
||||||
WHERE id_product NOT IN ('.implode(',',$exclude_ids).')
|
WHERE id_product NOT IN (' . implode(',', $exclude_ids) . ')
|
||||||
GROUP BY supplier_reference
|
GROUP BY supplier_reference
|
||||||
) as b
|
) as b
|
||||||
ON p.`id_product`= b.maxid
|
ON p.`id_product`= b.maxid
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` c
|
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c
|
||||||
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
|
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_customs` cu
|
LEFT JOIN `' . _DB_PREFIX_ . 'product_customs` cu
|
||||||
ON (cu.`id_product` = p.`id_product`)
|
ON (cu.`id_product` = p.`id_product`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` ac
|
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` ac
|
||||||
ON (ac.`id_product_attribute` = b.`id_product_attribute`)
|
ON (ac.`id_product_attribute` = b.`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_lang` = 2)
|
ON (al.`id_attribute` = ac.`id_attribute` AND al.`id_lang` = 2)
|
||||||
WHERE b.`supplier_reference` IN ("'.implode('","',$refs).'")
|
WHERE b.`supplier_reference` IN ("' . implode('","', $refs) . '")
|
||||||
AND p.`id_product` IS NOT NULL
|
AND p.`id_product` IS NOT NULL
|
||||||
ORDER BY c.`position`
|
ORDER BY c.`position`
|
||||||
') as $row) {
|
') as $row) {
|
||||||
// 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++;
|
||||||
// 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'];
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if($row['at_ref']!='' && isset($products[$row['at_ref']])){
|
if ($row['at_ref'] != '' && isset($products[$row['at_ref']])) {
|
||||||
$products[$row['at_ref']] = array_merge($products[$row['at_ref']], $row);
|
$products[$row['at_ref']] = array_merge($products[$row['at_ref']], $row);
|
||||||
$product_found++;
|
$product_found++;
|
||||||
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'];
|
||||||
}
|
}
|
||||||
} 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++;
|
||||||
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'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$timer_table[] = 'Ref product attr gathered at '.(microtime(true)-$callStartTime);
|
||||||
$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('
|
||||||
@ -320,7 +354,7 @@ class AdminAntWp extends AdminTab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$timer_table[] = 'Additional info gathered at '.(microtime(true)-$callStartTime);
|
||||||
foreach (Db::getInstance()->executeS('
|
foreach (Db::getInstance()->executeS('
|
||||||
SELECT at.`ean13`, at.`supplier_reference` as at_ref, p.`supplier_reference`, pl.*
|
SELECT at.`ean13`, at.`supplier_reference` as at_ref, p.`supplier_reference`, pl.*
|
||||||
FROM '._DB_PREFIX_.'product p
|
FROM '._DB_PREFIX_.'product p
|
||||||
@ -353,14 +387,24 @@ class AdminAntWp extends AdminTab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$timer_table[] = 'Additional info (attr) gathered at '.(microtime(true)-$callStartTime);
|
||||||
}
|
}
|
||||||
$params['lines'] = $products;
|
$params['lines'] = $products;
|
||||||
if(!empty($params['lines'])){
|
if(!empty($params['lines'])){
|
||||||
$wp = new GenerateWp();
|
$wp = new GenerateWp();
|
||||||
$wp->generate($params);
|
$wp->generate($params, $timer_table, $callStartTime);
|
||||||
$filename = str_replace(' ', '_', $filename);
|
$filename = str_replace(' ', '_', $filename);
|
||||||
$wp->objWriter->save(dirname(__FILE__).'/'.$filename.'.xlsx');
|
$wp->objWriter->save(__DIR__ .'/'.$filename.'.xlsx');
|
||||||
$this->_html .= HelperFormBootstrap::displaySuccess('Génération complète <br><a class="btn btn-primary btn-xs" href="../modules/ant_wp/'.$filename.'.xlsx" download="'.$filename.'.xlsx">Télécharger le XLS</a><br>Produits trouvés : '.$product_found.'<br>Produits nouveaux : '.$new_products);
|
$timer_table_formatted = implode('<br>', $timer_table);
|
||||||
|
$duplicated_formatted = '';
|
||||||
|
if (!empty($this->report[self::DUPLICATED_REFS])) {
|
||||||
|
$duplicated_formatted = '<hr>Duplications de Reférences<br><p style="color:darkred">' . implode('<br>', $this->report[self::DUPLICATED_REFS]). '</p>';
|
||||||
|
}
|
||||||
|
if (!empty($this->report[self::DUPLICATED_EANS])) {
|
||||||
|
$duplicated_formatted .= '<hr>Duplications d\'EANs<br><p style="color:darkred">' . implode('<br>', $this->report[self::DUPLICATED_EANS]) . '</p>';
|
||||||
|
}
|
||||||
|
$this->_html .= HelperFormBootstrap::displaySuccess('Génération complète <br><a class="btn btn-primary btn-xs" href="../modules/ant_wp/'.$filename.'.xlsx" download="'.$filename.'.xlsx">Télécharger le XLS</a>'.
|
||||||
|
'<br>Produits trouvés : '.$product_found.'<br>Produits nouveaux : '.$new_products.$duplicated_formatted.'<p style="font-size: 6px"><br>Timers : <br>'.$timer_table_formatted.'</p>');
|
||||||
} else {
|
} else {
|
||||||
$this->_html .= HelperFormBootstrap::displayErrors($this->l('Veuillez charger un fichier correct !'));
|
$this->_html .= HelperFormBootstrap::displayErrors($this->l('Veuillez charger un fichier correct !'));
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user