From 69fbd79eee4c7894a40f9dd619d21ba89ee6d708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 4 Dec 2012 11:38:47 +0100 Subject: [PATCH] [-] BO: Fix #PSCFV-4889 don't delete product if physical stock > 0 --- controllers/admin/AdminProductsController.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 651987711..f826f226d 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -536,13 +536,17 @@ class AdminProductsControllerCore extends AdminController $this->errors[] = Tools::displayError('You cannot delete the product because there is physical stock left or supply orders in progress.'); } - if ($object->delete()) + if (!count($this->errors)) { - $id_category = (int)Tools::getValue('id_category'); - $category_url = empty($id_category) ? '' : '&id_category='.(int)$id_category; - $this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token.$category_url; + if ($object->delete()) + { + $id_category = (int)Tools::getValue('id_category'); + $category_url = empty($id_category) ? '' : '&id_category='.(int)$id_category; + $this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token.$category_url; + } + else + $this->errors[] = Tools::displayError('An error occurred during deletion.'); } - $this->errors[] = Tools::displayError('An error occurred during deletion.'); } } else @@ -632,10 +636,8 @@ class AdminProductsControllerCore extends AdminController $real_quantity = $stock_manager->getProductRealQuantities($product->id, 0); if ($physical_quantity > 0 || $real_quantity > $physical_quantity) $this->errors[] = sprintf(Tools::displayError('You cannot delete the product #%d because there is physical stock left or supply orders in progress.'), $product->id); - else - $success &= $product->delete(); } - else + if (!count($this->errors)) $success &= $product->delete(); } }