diff --git a/classes/Product.php b/classes/Product.php index 8ba9637a0..d8cb68bad 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -2198,14 +2198,13 @@ class ProductCore extends ObjectModel 'id_shop' => (int)$this->id_shop ); } - Db::getInstance()->execute( 'DELETE FROM `'._DB_PREFIX_.'product_carrier` WHERE id_product = '.(int)$this->id.' AND id_shop = '.(int)$this->id_shop ); - - Db::getInstance()->insert('product_carrier', $data); + if (count($data)) + Db::getInstance()->insert('product_carrier', $data); } /** diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 4cd642ce1..836c66b4c 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -3396,13 +3396,13 @@ class AdminProductsControllerCore extends AdminController protected function addCarriers() { - if (Tools::getValue('carriers')) + if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) { - if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) - { - if (Tools::getValue('carriers')) - $product->setCarriers(Tools::getValue('carriers')); - } + $carriers = array(); + + if (Tools::getValue('carriers')) + $carriers = Tools::getValue('carriers'); + $product->setCarriers($carriers); } }