[*] classes : new constant Product::PTYPE_SIMPLE /PTYPE_PACK/PTYPE_VIRTUAL
This commit is contained in:
@@ -67,15 +67,15 @@
|
||||
<div>
|
||||
<label>{l s='Type:'}</label>
|
||||
<label style="font-weight:normal;width:100px;text-align:center;">
|
||||
<input type="radio" name="type_product" id="simple_product" value="0" />
|
||||
<input type="radio" name="type_product" id="simple_product" value="{Product::PTYPE_SIMPLE}" />
|
||||
{l s='Product'}
|
||||
</label>
|
||||
<label style="font-weight:normal;width:100px;text-align:center;">
|
||||
<input type="radio" name="type_product" id="pack_product" value="1" />
|
||||
<input type="radio" name="type_product" id="pack_product" value="{Product::PTYPE_PACK}" {if $is_pack}checked="checked"{/if} />
|
||||
{l s='Pack'}
|
||||
</label>
|
||||
<label style="font-weight:normal;width:500px;text-align:center;">
|
||||
<input type="radio" name="type_product" id="virtual_product" value="2" />
|
||||
<input type="radio" name="type_product" id="virtual_product" value="{Product::PTYPE_VIRTUAL}" />
|
||||
{l s='Virtual Product (services, booking and downloadable products)'}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user