[*] classes : new constant Product::PTYPE_SIMPLE /PTYPE_PACK/PTYPE_VIRTUAL
This commit is contained in:
@@ -67,15 +67,15 @@
|
|||||||
<div>
|
<div>
|
||||||
<label>{l s='Type:'}</label>
|
<label>{l s='Type:'}</label>
|
||||||
<label style="font-weight:normal;width:100px;text-align:center;">
|
<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'}
|
{l s='Product'}
|
||||||
</label>
|
</label>
|
||||||
<label style="font-weight:normal;width:100px;text-align:center;">
|
<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'}
|
{l s='Pack'}
|
||||||
</label>
|
</label>
|
||||||
<label style="font-weight:normal;width:500px;text-align:center;">
|
<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)'}
|
{l s='Virtual Product (services, booking and downloadable products)'}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -365,6 +365,12 @@ class ProductCore extends ObjectModel
|
|||||||
|
|
||||||
const CUSTOMIZE_FILE = 0;
|
const CUSTOMIZE_FILE = 0;
|
||||||
const CUSTOMIZE_TEXTFIELD = 1;
|
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)
|
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();
|
$object = new $this->className();
|
||||||
$this->_removeTaxFromEcotax();
|
$this->_removeTaxFromEcotax();
|
||||||
$this->copyFromPost($object, $this->table);
|
$this->copyFromPost($object, $this->table);
|
||||||
|
|
||||||
if ($object->add())
|
if ($object->add())
|
||||||
{
|
{
|
||||||
$this->addCarriers();
|
$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 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);
|
StockAvailable::setProductOutOfStock($object->id, 1);
|
||||||
else
|
else
|
||||||
StockAvailable::setProductOutOfStock($object->id, 2);
|
StockAvailable::setProductOutOfStock($object->id, 2);
|
||||||
@@ -1546,6 +1547,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
public function checkProduct()
|
public function checkProduct()
|
||||||
{
|
{
|
||||||
$className = 'Product';
|
$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);
|
$rules = call_user_func(array($this->className, 'getValidationRules'), $this->className);
|
||||||
$default_language = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));
|
$default_language = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));
|
||||||
$languages = Language::getLanguages(false);
|
$languages = Language::getLanguages(false);
|
||||||
@@ -3843,12 +3845,19 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
$this->tpl_form_vars['input_namepack_items'] = $input_namepack_items;
|
$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)
|
public function updatePackItems($product)
|
||||||
{
|
{
|
||||||
Pack::deleteItems($product->id);
|
Pack::deleteItems($product->id);
|
||||||
|
|
||||||
// lines format: QTY x ID-QTY x 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');
|
$items = Tools::getValue('inputPackItems');
|
||||||
$lines = array_unique(explode('-', $items));
|
$lines = array_unique(explode('-', $items));
|
||||||
|
|||||||
Reference in New Issue
Block a user