From c7705ea34e4dbcdf87cbec13cef264491af589c6 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Fri, 1 Jun 2012 09:16:40 +0000 Subject: [PATCH] [-] BO : fixed bug #PSCFV-2624 - Error after deleting supplier associated with a product git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15789 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/ProductSupplier.php | 2 +- controllers/admin/AdminSuppliersController.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/ProductSupplier.php b/classes/ProductSupplier.php index bcc65863e..810590568 100644 --- a/classes/ProductSupplier.php +++ b/classes/ProductSupplier.php @@ -195,7 +195,7 @@ class ProductSupplierCore extends ObjectModel public static function getSupplierCollection($id_product, $group_by_supplier = true) { $suppliers = new Collection('ProductSupplier'); - $suppliers->where('id_product', '=', $id_product); + $suppliers->where('id_product', '=', (int)$id_product); if ($group_by_supplier) $suppliers->groupBy('id_supplier'); diff --git a/controllers/admin/AdminSuppliersController.php b/controllers/admin/AdminSuppliersController.php index 2be2512e6..901ab9ec1 100644 --- a/controllers/admin/AdminSuppliersController.php +++ b/controllers/admin/AdminSuppliersController.php @@ -400,6 +400,9 @@ class AdminSuppliersControllerCore extends AdminController $this->errors[] = $this->l('It is not possible to delete a supplier if there are any pending supply order.'); else { + //delete all product_supplier linked to this supplier + Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'product_supplier` WHERE `id_supplier`='.(int)$obj->id); + $id_address = Address::getAddressIdBySupplierId($obj->id); $address = new Address($id_address); if (Validate::isLoadedObject($address))