Merge branch 'ticket-10805' into develop
This commit is contained in:
commit
a33e2da7ca
@ -245,7 +245,7 @@ class AdminProducts extends AdminTab
|
||||
Tools::redirectAdmin($currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&token='.($token ? $token : $this->token));
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('clean_positionproduct')) {
|
||||
if (Tools::isSubmit('clean_positionproduct') || Tools::isSubmit('has_to_cleanproduct')) {
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
if ($cookie->id_employee == 1) {
|
||||
@ -255,31 +255,42 @@ class AdminProducts extends AdminTab
|
||||
WHERE cp.`id_category` = '.(int)$this->_category->id.'
|
||||
ORDER BY cp.`position` ASC
|
||||
');
|
||||
if (Tools::isSubmit('has_to_cleanproduct')) {
|
||||
$hasToBeCleaned = array();
|
||||
foreach ($category_products as $key => $cat_product) {
|
||||
if(!Validate::isLoadedObject($product = new Product((int)$cat_product['id_product']))){
|
||||
$hasToBeCleaned[] = (int)$cat_product['id_product'];
|
||||
}
|
||||
}
|
||||
echo '<pre>';var_dump($hasToBeCleaned);echo '</pre>';die();
|
||||
}
|
||||
if (Tools::isSubmit('clean_positionproduct')) {
|
||||
|
||||
// Position mise à 0
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = 0
|
||||
WHERE `id_category` = '.(int)$this->_category->id
|
||||
);
|
||||
// Position mise à 0
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = 0
|
||||
WHERE `id_category` = '.(int)$this->_category->id
|
||||
);
|
||||
|
||||
$pos = 0;
|
||||
foreach ($category_products as $key => $cat_product) {
|
||||
if(Validate::isLoadedObject($product = new Product((int)$cat_product['id_product']))){
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = '. (int)($pos) .'
|
||||
WHERE `id_product` = '.(int)$cat_product['id_product'].'
|
||||
AND `id_category`='.(int)$this->_category->id
|
||||
);
|
||||
$pos++;
|
||||
} else {
|
||||
Db::getInstance()->Execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'category_product`
|
||||
WHERE `id_category` = '.(int)$this->_category->id.'
|
||||
AND `id_product` = '.(int)$cat_product['id_product'].'
|
||||
');
|
||||
continue;
|
||||
$pos = 0;
|
||||
foreach ($category_products as $key => $cat_product) {
|
||||
if(Validate::isLoadedObject($product = new Product((int)$cat_product['id_product']))){
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = '. (int)($pos) .'
|
||||
WHERE `id_product` = '.(int)$cat_product['id_product'].'
|
||||
AND `id_category`='.(int)$this->_category->id
|
||||
);
|
||||
$pos++;
|
||||
} else {
|
||||
Db::getInstance()->Execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'category_product`
|
||||
WHERE `id_category` = '.(int)$this->_category->id.'
|
||||
AND `id_product` = '.(int)$cat_product['id_product'].'
|
||||
');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1981,7 +1992,10 @@ class AdminProducts extends AdminTab
|
||||
echo '<p>'.$this->l('Order by product name').'</p>';
|
||||
}
|
||||
if((int)$this->_category->id_oarent !=1 && $cookie->id_employee==1){
|
||||
echo '<p><input type="submit" class="button" name="clean_position'.$this->table.'" value="'.$this->l('Order products').'" /></p>';
|
||||
echo '<p>
|
||||
<input type="submit" class="button" name="has_to_clean'.$this->table.'" value="'.$this->l('Produits à cleaner').'" />
|
||||
<input type="submit" class="button" name="clean_position'.$this->table.'" value="'.$this->l('Clean positions').'" />
|
||||
</p>';
|
||||
echo '<p>'.$this->l('Re-Order by product position, clean all position of the category').'</p>';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user