diff --git a/admin-dev/themes/default/template/products/informations.tpl b/admin-dev/themes/default/template/products/informations.tpl
index 709e04a1d..19139f0c5 100644
--- a/admin-dev/themes/default/template/products/informations.tpl
+++ b/admin-dev/themes/default/template/products/informations.tpl
@@ -67,15 +67,15 @@
diff --git a/classes/Product.php b/classes/Product.php
index 02c556d20..ced90e453 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -365,6 +365,12 @@ class ProductCore extends ObjectModel
const CUSTOMIZE_FILE = 0;
const CUSTOMIZE_TEXTFIELD = 1;
+
+
+ // Note: prefix is "PTYPE" because TYPE_ is used in ObjectModel (definition)
+ const PTYPE_SIMPLE = 0;
+ const PTYPE_PACK = 1;
+ const PTYPE_VIRTUAL = 2;
public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
{
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index b046fe02e..840574899 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -1398,6 +1398,7 @@ class AdminProductsControllerCore extends AdminController
$object = new $this->className();
$this->_removeTaxFromEcotax();
$this->copyFromPost($object, $this->table);
+
if ($object->add())
{
$this->addCarriers();
@@ -1421,7 +1422,7 @@ class AdminProductsControllerCore extends AdminController
}
// If the product is virtual, set out_of_stock = 1 (allow sales when out of stock)
- if (Tools::getValue('type_product') == 2)
+ if (Tools::getValue('type_product') == Product::PTYPE_VIRTUAL)
StockAvailable::setProductOutOfStock($object->id, 1);
else
StockAvailable::setProductOutOfStock($object->id, 2);
@@ -1546,6 +1547,7 @@ class AdminProductsControllerCore extends AdminController
public function checkProduct()
{
$className = 'Product';
+ // @todo : the call_user_func seems to contains only statics values (clasName = "Product")
$rules = call_user_func(array($this->className, 'getValidationRules'), $this->className);
$default_language = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));
$languages = Language::getLanguages(false);
@@ -3843,12 +3845,19 @@ class AdminProductsControllerCore extends AdminController
$this->tpl_form_vars['input_namepack_items'] = $input_namepack_items;
}
+ /**
+ * delete all items in pack, then check if type_product value is 2.
+ * if yes, add the pack items from input "inputPackItems"
+ *
+ * @param Product $product
+ * @return boolean
+ */
public function updatePackItems($product)
{
Pack::deleteItems($product->id);
// lines format: QTY x ID-QTY x ID
- if (Tools::getValue('type_product') == 1)
+ if (Tools::getValue('type_product') == Product::PTYPE_PACK)
{
$items = Tools::getValue('inputPackItems');
$lines = array_unique(explode('-', $items));