diff --git a/classes/Product.php b/classes/Product.php index 1856f3a07..1373f01f6 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -658,7 +658,8 @@ class ProductCore extends ObjectModel !$this->deleteSceneProducts() || !$this->deleteSearchIndexes() || !$this->deleteAccessories() || - !$this->deleteFromAccessories()) + !$this->deleteFromAccessories() || + !$this->deleteFromSupplier()) return false; if ($id = ProductDownload::getIdFromIdProduct($this->id)) @@ -680,6 +681,16 @@ class ProductCore extends ObjectModel return $return; } + public function deleteFromSupplier() + { + $return = Db::getInstance()->execute( + 'DELETE FROM `'._DB_PREFIX_.'product_supplier` + WHERE `id_product` = '.(int)$this->id + ); + + return $return; + } + /** * addToCategories add this product to the category/ies if not exists. * diff --git a/controllers/admin/AdminSuppliersController.php b/controllers/admin/AdminSuppliersController.php index 9e931a81f..8bc18a261 100644 --- a/controllers/admin/AdminSuppliersController.php +++ b/controllers/admin/AdminSuppliersController.php @@ -392,8 +392,11 @@ class AdminSuppliersControllerCore extends AdminController else { $address = new Address($obj->id_address); - $address->deleted = 1; - $address->save(); + if (Validate::isLoadedObject($address)) + { + $address->deleted = 1; + $address->save(); + } return parent::postProcess(); } }