Merge branch 'ticket-10122' into develop
This commit is contained in:
commit
a49e70ff08
@ -174,6 +174,7 @@ class AdminBraderie extends AdminTab
|
||||
data: {
|
||||
parent_category: $("#sale").val(),
|
||||
category: $("#category").val(),
|
||||
ean: $("#input_ean").val(),
|
||||
storage: $("#input_storage").val(),
|
||||
product: $("#hidden_product_id").val(),
|
||||
quantity: $("#input_quantity").val(),
|
||||
@ -222,6 +223,7 @@ class AdminBraderie extends AdminTab
|
||||
data: {
|
||||
parent_category: $("#sale").val(),
|
||||
category: $("#category").val(),
|
||||
ean: $("#input_ean").val(),
|
||||
storage: $("#input_storage").val(),
|
||||
product: $("#hidden_product_id").val(),
|
||||
quantity: $("#input_quantity").val(),
|
||||
|
@ -34,9 +34,6 @@ function getCategories()
|
||||
return Tools::displayError('Catégorie invalide');
|
||||
}
|
||||
|
||||
//$db = Db::getInstance();
|
||||
//$sql = 'SELECT * FROM `'._DB_PREFIX_.'privatesale_category` pc LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON pc.`id_category` = cl.`id_category` WHERE pc.`id_sale` = '.$id_sale.' AND cl.`id_lang` = '.(int)$cookie->id_lang;
|
||||
|
||||
return Db::getInstance()->ExecuteS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
@ -61,8 +58,6 @@ function getProductId()
|
||||
return Tools::displayError('Code EAN invalide');
|
||||
}
|
||||
|
||||
//$db = Db::getInstance();
|
||||
//$sql = 'SELECT `'._DB_PREFIX_.'product_lang`.`id_product`, `'._DB_PREFIX_.'product_lang`.`name` FROM `'._DB_PREFIX_.'product` LEFT JOIN `'._DB_PREFIX_.'product_lang` ON `'._DB_PREFIX_.'product`.id_product = `'._DB_PREFIX_.'product_lang`.id_product WHERE `ean13` = '.$ean.' AND `id_lang` = '.(int)$cookie->id_lang.' ORDER BY `date_add` DESC LIMIT 1';
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT p.`id_product`, p.`reference`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
@ -74,12 +69,6 @@ function getProductId()
|
||||
');
|
||||
|
||||
if (empty($result)) {
|
||||
//$sql = 'SELECT * FROM `'._DB_PREFIX_.'product_attribute` WHERE `ean13` = '.pSQL($ean).' ORDER BY `id_product_attribute` DESC LIMIT 1';
|
||||
/*$sql = 'SELECT * FROM `'._DB_PREFIX_.'product_lang` WHERE `id_product` = '.(int)($result[0]['id_product']).' LIMIT 1';
|
||||
$tmp = $db->ExecuteS($sql)[0];
|
||||
$result[0]['name'] = $tmp['name'];
|
||||
$result[0]['reference'] = ($result[0]['reference']) ? $result[0]['reference'] : $tmp['reference'];*/
|
||||
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT pa.*, pl.`name`, p.`reference` as product_reference, al.`name` as attribute_name
|
||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||
@ -96,6 +85,55 @@ function getProductId()
|
||||
|
||||
}
|
||||
|
||||
/*$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($ean).'
|
||||
AND cl.`id_lang` = '.(int)$cookie->id_lang.'
|
||||
AND ps.`braderie`= 0
|
||||
ORDER BY p.`date_add` ASC'
|
||||
);
|
||||
if(!isset($category_name) || empty($category_name)) {
|
||||
$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_attribute` pa ON (pa.`id_product` = pps.`id_product`)
|
||||
WHERE pa.`ean13` = '.pSQL($ean).' AND cl.`id_lang` = '.(int)$cookie->id_lang.'
|
||||
AND ps.`braderie`= 0
|
||||
ORDER BY pa.`id_product_attribute` ASC'
|
||||
);
|
||||
}
|
||||
$result['category_name'] = $category_name['name'];
|
||||
|
||||
$product_name = Db::getInstance()->getRow('
|
||||
SELECT pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||
WHERE p.`ean13` = '.pSQL($ean).'
|
||||
AND pl.`id_lang` = '.(int)$cookie->id_lang.'
|
||||
ORDER BY p.`date_add` ASC
|
||||
');
|
||||
|
||||
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`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (al.`id_attribute` = pac.`id_attribute`)
|
||||
WHERE pa.`ean13` = '.pSQL($ean).'
|
||||
AND pl.`id_lang` = '.(int)$cookie->id_lang.'
|
||||
ORDER BY p.`date_add` ASC
|
||||
');
|
||||
}
|
||||
$result['product_name'] = $product_name['name'];*/
|
||||
|
||||
if (!empty($result)) {
|
||||
return $result;
|
||||
} else {
|
||||
@ -136,6 +174,9 @@ function addToSellout()
|
||||
return Tools::displayError('L\'emplacement n\'est pas valide');
|
||||
}
|
||||
|
||||
//$category_name = Tools::getValue('category_name', false);
|
||||
//$product_name = Tools::getValue('product_name', false);
|
||||
$ean13 = Tools::getValue('ean', false);
|
||||
$id_attribute = (int)Tools::getValue('attribute', false);
|
||||
|
||||
// duplication produit classique
|
||||
@ -149,46 +190,71 @@ function addToSellout()
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
foreach ($languages as $key => $language) {
|
||||
/*$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`)
|
||||
WHERE pps.`id_product` = '.(int)$id_product_old.'
|
||||
AND cl.`id_lang` = '.(int)$language['id_lang']
|
||||
);*/
|
||||
/*if(!$category_name) {
|
||||
$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`)
|
||||
WHERE pps.`id_product` = '.(int)$id_product_old.'
|
||||
AND cl.`id_lang` = '.(int)$language['id_lang']
|
||||
);
|
||||
$category_name = $category_name['name'];
|
||||
}*/
|
||||
|
||||
// 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($product->ean13).'
|
||||
WHERE p.`ean13` = '.pSQL($ean13).'
|
||||
AND cl.`id_lang` = '.(int)$language['id_lang'].'
|
||||
ORDER BY p.`date_add` ASC LIMIT 1'
|
||||
);
|
||||
$name = Db::getInstance()->getRow('
|
||||
SELECT pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||
WHERE p.`ean13` = '.pSQL($product->ean13).'
|
||||
AND pl.`id_lang` = '.(int)$language['id_lang'].'
|
||||
AND ps.`braderie`= 0
|
||||
ORDER BY p.`date_add` ASC'
|
||||
);
|
||||
if (!$name) {
|
||||
$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`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (al.`id_attribute` = pac.`id_attribute`)
|
||||
WHERE p.`ean13` = '.pSQL($product->ean13).'
|
||||
AND pl.`id_lang` = '.(int)$language['id_lang'].'
|
||||
ORDER BY pa.`id_product_attribute` ASC
|
||||
');
|
||||
if(!isset($category_name) || empty($category_name)) {
|
||||
$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_attribute` pa ON (pa.`id_product` = pps.`id_product`)
|
||||
WHERE pa.`ean13` = '.pSQL($ean13).' AND cl.`id_lang` = '.(int)$language['id_lang'].'
|
||||
AND ps.`braderie`= 0
|
||||
ORDER BY pa.`id_product_attribute` ASC'
|
||||
);
|
||||
}
|
||||
$product->name[(int)$language['id_lang']] = $name['name'].' - '.strtoupper($category_name['name']);
|
||||
|
||||
if ($ean13) {
|
||||
// récupération du nom original (nom du premier produit ajouté)
|
||||
$product_name = Db::getInstance()->getRow('
|
||||
SELECT pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||
WHERE p.`ean13` = '.pSQL($ean13).'
|
||||
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('
|
||||
SELECT pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = pa.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (al.`id_attribute` = pac.`id_attribute`)
|
||||
WHERE pa.`ean13` = '.pSQL($ean13).'
|
||||
AND pl.`id_lang` = '.(int)$language['id_lang'].'
|
||||
ORDER BY p.`date_add` ASC
|
||||
');
|
||||
}
|
||||
}
|
||||
|
||||
$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']);
|
||||
}
|
||||
|
||||
$product->id_category_default = (int)$category;
|
||||
|
Loading…
Reference in New Issue
Block a user