diff --git a/adm/tabs/AdminProducts.php b/adm/tabs/AdminProducts.php index 5776b833..6c5dd90a 100755 --- a/adm/tabs/AdminProducts.php +++ b/adm/tabs/AdminProducts.php @@ -683,7 +683,38 @@ class AdminProducts extends AdminTab $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } - /* Product images management */ + /* @Override - Antadis, delete some images in same time */ + elseif (Tools::isSubmit('deleteImages') && Tools::getValue('ids_image')) + { + $ids_image = Tools::getValue('ids_image'); + if ($this->tabAccess['edit'] === '1') + { + foreach ($ids_image as $key => $id_image) { + if(Validate::isUnsignedId((int)$id_image) AND Validate::isLoadedObject($image = new Image((int)$id_image))) { + $image->delete(); + + if (!Image::getCover($image->id_product)) + { + $first_img = Db::getInstance()->getRow(' + SELECT `id_image` FROM `'._DB_PREFIX_.'image` + WHERE `id_product` = '.(int)($image->id_product)); + Db::getInstance()->Execute(' + UPDATE `'._DB_PREFIX_.'image` + SET `cover` = 1 + WHERE `id_image` = '.(int)($first_img['id_image'])); + } + @unlink(_PS_TMP_IMG_DIR_.'/product_'.$image->id_product.'.jpg'); + @unlink(_PS_TMP_IMG_DIR_.'/product_mini_'.$image->id_product.'.jpg'); + } + } + if(isset($image) && Validate::isLoadedObject($image)) { + Tools::redirectAdmin($currentIndex.'&id_product='.$image->id_product.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=1'.'&token='.($token ? $token : $this->token)); + } else { + $this->_errors[] = Tools::displayError('An error occured.'); + } + } + } + elseif (($id_image = (int)(Tools::getValue('id_image'))) AND Validate::isUnsignedId($id_image) AND Validate::isLoadedObject($image = new Image($id_image))) { /* PrestaShop demo mode */ @@ -3810,6 +3841,7 @@ class AdminProducts extends AdminTab + @@ -3825,6 +3857,7 @@ class AdminProducts extends AdminTab // echo $this->_positionJS() echo ' + @@ -3863,6 +3896,7 @@ class AdminProducts extends AdminTab
  '.$this->l('Image').'   '.$this->l('Position').'
'.htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8').'
+

'; echo '