[-] BO : fixed bug #PSCFV-2624 - Error after deleting supplier associated with a product
This commit is contained in:
@@ -195,7 +195,7 @@ class ProductSupplierCore extends ObjectModel
|
|||||||
public static function getSupplierCollection($id_product, $group_by_supplier = true)
|
public static function getSupplierCollection($id_product, $group_by_supplier = true)
|
||||||
{
|
{
|
||||||
$suppliers = new Collection('ProductSupplier');
|
$suppliers = new Collection('ProductSupplier');
|
||||||
$suppliers->where('id_product', '=', $id_product);
|
$suppliers->where('id_product', '=', (int)$id_product);
|
||||||
|
|
||||||
if ($group_by_supplier)
|
if ($group_by_supplier)
|
||||||
$suppliers->groupBy('id_supplier');
|
$suppliers->groupBy('id_supplier');
|
||||||
|
|||||||
@@ -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.');
|
$this->errors[] = $this->l('It is not possible to delete a supplier if there are any pending supply order.');
|
||||||
else
|
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);
|
$id_address = Address::getAddressIdBySupplierId($obj->id);
|
||||||
$address = new Address($id_address);
|
$address = new Address($id_address);
|
||||||
if (Validate::isLoadedObject($address))
|
if (Validate::isLoadedObject($address))
|
||||||
|
|||||||
Reference in New Issue
Block a user