This commit is contained in:
Michael RICOIS 2018-01-26 15:15:11 +01:00
parent c13496d8e1
commit e2ff256675

View File

@ -141,7 +141,7 @@ function addToSellout()
$ean13 = Tools::getValue('ean', false);
$id_attribute = (int)Tools::getValue('attribute', false);
// duplication produit classique
// Duplication produit classique
$product = new Product($product_id);
$id_product_old = $product->id;
unset($product->id);
@ -152,20 +152,19 @@ function addToSellout()
$languages = Language::getLanguages(false);
foreach ($languages as $key => $language) {
// récupération de la catégorie originale (nom de la première catégorie)
// Récupération de la catégorie originale (nom de la première catégorie)
$category_name = Db::getInstance()->getRow('
SELECT cl.`name`
FROM `'._DB_PREFIX_.'category_lang` cl
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps ON (ps.`id_category` = cl.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` pps ON (pps.`id_sale` = ps.`id_sale`)
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = pps.`id_product`)
WHERE p.`ean13` = '.pSQL($ean13).'
AND cl.`id_lang` = '.(int)$language['id_lang'].'
WHERE p.`ean13` = '.pSQL($ean13).' AND cl.`id_lang` = '.(int)$language['id_lang'].'
AND ps.`braderie`= 0
ORDER BY p.`date_add` ASC'
);
if(!isset($category_name) || empty($category_name)) {
// No name, search in attributes
if (!isset($category_name) || empty($category_name)) {
$category_name = Db::getInstance()->getRow('
SELECT cl.`name`
FROM `'._DB_PREFIX_.'category_lang` cl
@ -179,7 +178,7 @@ function addToSellout()
}
if ($ean13) {
// récupération du nom original (nom du premier produit ajouté)
// Récupération du nom original (nom du premier produit ajouté)
$product_name = Db::getInstance()->getRow('
SELECT pl.`name`
FROM `'._DB_PREFIX_.'product` p
@ -188,9 +187,9 @@ function addToSellout()
AND pl.`id_lang` = '.(int)$language['id_lang'].'
ORDER BY p.`date_add` ASC
');
if(!isset($product_name) || empty($product_name)) {
$product_name = Db::getInstance()->getRow('
// No name, search in attributes
if (!isset($product_name) || empty($product_name)) {
$product_name = Db::getInstance()->getRow('
SELECT pl.`name`
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = pa.`id_product`)
@ -204,7 +203,7 @@ function addToSellout()
}
}
$name = (isset($product_name) && !empty($product_name))? $product_name['name'] : $product->name[(int)$language['id_lang']];
$name = (isset($product_name) && !empty($product_name)) ? $product_name['name'] : $product->name[(int)$language['id_lang']];
$product->name[(int)$language['id_lang']] = $name.' - '.strtoupper($category_name['name']);
}
@ -219,14 +218,14 @@ function addToSellout()
FROM `'._DB_PREFIX_.'product_customs`
WHERE `id_product` = '.(int)$id_product_old.'
');
if($customs){
if ($customs) {
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'product_customs`
VALUES (
'.(int) $product->id.',
"'.(!empty($customs['nc8'])?$customs['nc8']:'').'",
"'.(!empty($customs['id_country'])?$customs['id_country']:'').'",
'.($customs['random']?1:0).'
"'.(!empty($customs['nc8']) ? $customs['nc8'] : '').'",
"'.(!empty($customs['id_country']) ? $customs['id_country'] : '').'",
'.($customs['random'] ? 1 : 0).'
)
');
}
@ -244,11 +243,13 @@ function addToSellout()
$product->UpdateCategories(array((int)$category,(int)$parent_category));
if ($product->hasAttributes())
if ($product->hasAttributes()) {
Product::updateDefaultAttribute($product->id);
}
Image::duplicateProductImages($id_product_old, $product->id, $combinationImages);
}
return Tools::displayError('Le produit a été ajouté à la braderie');
}