// Add support of list of values in objects definition and set default value for product->condition
This commit is contained in:
1 parent
e73df61f45
commit
6ed4874326
2 files changed
+16
-5
No files matched your search
@@ -712,6 +712,17 @@ abstract class ObjectModelCore
|
|||||||
if (Tools::isEmpty($value))
|
if (Tools::isEmpty($value))
|
||||||
return 'Property '.get_class($this).'->'.$field.' is empty';
|
return 'Property '.get_class($this).'->'.$field.' is empty';
|
||||||
|
|
||||||
|
// Default value
|
||||||
|
if (!$value && !empty($data['default']))
|
||||||
|
{
|
||||||
|
$value = $data['default'];
|
||||||
|
$this->$field = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check field values
|
||||||
|
if (!empty($data['values']) && is_array($data['values']) && !in_array($value, $data['values']))
|
||||||
|
return 'Property '.get_class($this).'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')';
|
||||||
|
|
||||||
// Check field size
|
// Check field size
|
||||||
if (!empty($data['size']))
|
if (!empty($data['size']))
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-5
@@ -159,14 +159,14 @@ class ProductCore extends ObjectModel
|
|||||||
/** @var integer Number of uploadable files (concerning customizable products) */
|
/** @var integer Number of uploadable files (concerning customizable products) */
|
||||||
public $uploadable_files;
|
public $uploadable_files;
|
||||||
|
|
||||||
/** @var interger Number of text fields */
|
/** @var int Number of text fields */
|
||||||
public $text_fields;
|
public $text_fields;
|
||||||
|
|
||||||
/** @var boolean Product statuts */
|
/** @var boolean Product statuts */
|
||||||
public $active = 1;
|
public $active = true;
|
||||||
|
|
||||||
/** @var boolean Product available for order */
|
/** @var boolean Product available for order */
|
||||||
public $available_for_order = 1;
|
public $available_for_order = true;
|
||||||
|
|
||||||
/** @var string Object available order date */
|
/** @var string Object available order date */
|
||||||
public $available_date = '0000-00-00';
|
public $available_date = '0000-00-00';
|
||||||
@@ -175,7 +175,7 @@ class ProductCore extends ObjectModel
|
|||||||
public $condition;
|
public $condition;
|
||||||
|
|
||||||
/** @var boolean Show price of Product */
|
/** @var boolean Show price of Product */
|
||||||
public $show_price = 1;
|
public $show_price = true;
|
||||||
|
|
||||||
public $indexed = 0;
|
public $indexed = 0;
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ class ProductCore extends ObjectModel
|
|||||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
'available_for_order' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'available_for_order' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
'available_date' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
'available_date' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
||||||
'condition' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), // @todo enum ?
|
'condition' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'values' => array('new', 'used', 'refurbished'), 'default' => 'new'),
|
||||||
'show_price' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'show_price' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13', 'size' => 13),
|
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13', 'size' => 13),
|
||||||
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc', 'size' => 12),
|
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc', 'size' => 12),
|
||||||
|
|||||||
Reference in new issue
Block a user