// Add support of list of values in objects definition and set default value for product->condition
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12570 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -712,6 +712,17 @@ abstract class ObjectModelCore
|
||||
if (Tools::isEmpty($value))
|
||||
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
|
||||
if (!empty($data['size']))
|
||||
{
|
||||
|
||||
+5
-5
@@ -159,14 +159,14 @@ class ProductCore extends ObjectModel
|
||||
/** @var integer Number of uploadable files (concerning customizable products) */
|
||||
public $uploadable_files;
|
||||
|
||||
/** @var interger Number of text fields */
|
||||
/** @var int Number of text fields */
|
||||
public $text_fields;
|
||||
|
||||
/** @var boolean Product statuts */
|
||||
public $active = 1;
|
||||
public $active = true;
|
||||
|
||||
/** @var boolean Product available for order */
|
||||
public $available_for_order = 1;
|
||||
public $available_for_order = true;
|
||||
|
||||
/** @var string Object available order date */
|
||||
public $available_date = '0000-00-00';
|
||||
@@ -175,7 +175,7 @@ class ProductCore extends ObjectModel
|
||||
public $condition;
|
||||
|
||||
/** @var boolean Show price of Product */
|
||||
public $show_price = 1;
|
||||
public $show_price = true;
|
||||
|
||||
public $indexed = 0;
|
||||
|
||||
@@ -259,7 +259,7 @@ class ProductCore extends ObjectModel
|
||||
'active' => 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'),
|
||||
'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'),
|
||||
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13', 'size' => 13),
|
||||
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc', 'size' => 12),
|
||||
|
||||
Reference in New Issue
Block a user