diff --git a/classes/Product.php b/classes/Product.php index e5ba48b79..39680a78b 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -461,6 +461,11 @@ class ProductCore extends ObjectModel { if (!parent::add($autodate, $null_values)) return false; + + if ($this->getType() == Product::PTYPE_VIRTUAL) + StockAvailable::setProductOutOfStock((int)$this->id, 1); + else + StockAvailable::setProductOutOfStock((int)$this->id, 2); Hook::exec('actionProductSave', array('id_product' => $this->id)); return true; diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 81a9f1947..a68054208 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1584,12 +1584,6 @@ class AdminProductsControllerCore extends AdminController Search::indexation(false, $this->object->id); } - // If the product is virtual, set out_of_stock = 1 (allow sales when out of stock) - if (Tools::getValue('type_product') == Product::PTYPE_VIRTUAL) - StockAvailable::setProductOutOfStock($this->object->id, 1); - else - StockAvailable::setProductOutOfStock($this->object->id, 2); - // Save and preview if (Tools::isSubmit('submitAddProductAndPreview')) {