Merge branch 'alexandre-braderie' into develop
This commit is contained in:
commit
7500debda5
@ -101,7 +101,6 @@ class AdminBraderie extends AdminTab
|
||||
dataType: \'json\',
|
||||
data: { ean: $(this).val() },
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
if (response.name == null) {
|
||||
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
||||
$("#ean_from_product").empty();
|
||||
@ -167,7 +166,8 @@ class AdminBraderie extends AdminTab
|
||||
type: \'POST\',
|
||||
url: \''._MODULE_DIR_.'braderie/ajax.php?action=addToSellout'.'\',
|
||||
dataType: \'json\',
|
||||
data: {
|
||||
data: {
|
||||
parent_category: $("#sale").val(),
|
||||
category: $("#category").val(),
|
||||
storage: $("#input_storage").val(),
|
||||
product: $("#hidden_product_id").val(),
|
||||
|
@ -103,6 +103,12 @@ function getProductId()
|
||||
|
||||
function addToSellout()
|
||||
{
|
||||
$parent_category = (int)Tools::getValue('parent_category', false);
|
||||
if (!$parent_category || !is_int($parent_category)) {
|
||||
http_response_code(500);
|
||||
return Toold::displayError('La catégorie principale n\'est pas valide');
|
||||
}
|
||||
|
||||
$category = (int)Tools::getValue('category', false);
|
||||
if (!$category || !is_int($category)) {
|
||||
http_response_code(500);
|
||||
@ -160,6 +166,14 @@ function addToSellout()
|
||||
'". (int)($max_position + 1 ) ."'
|
||||
)");
|
||||
|
||||
$max_position_in_parent = Db::getInstance()->getValue("SELECT MAX(cp.`position`) AS max FROM `"._DB_PREFIX_."category_product` cp WHERE cp.`id_category`=" . (int)$parent_category);
|
||||
$add_parent_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
|
||||
VALUES (
|
||||
'". $product->id ."',
|
||||
'". (int)$parent_category ."',
|
||||
'". (int)($max_position_in_parent + 1 ) ."'
|
||||
)");
|
||||
|
||||
if ($product->hasAttributes())
|
||||
Product::updateDefaultAttribute($product->id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user