Constants

TYPE_INT

TYPE_INT

List of field types

TYPE_BOOL

TYPE_BOOL

TYPE_STRING

TYPE_STRING

TYPE_FLOAT

TYPE_FLOAT

TYPE_DATE

TYPE_DATE

TYPE_HTML

TYPE_HTML

TYPE_NOTHING

TYPE_NOTHING

TYPE_SQL

TYPE_SQL

FORMAT_COMMON

FORMAT_COMMON

List of data to format

FORMAT_LANG

FORMAT_LANG

FORMAT_SHOP

FORMAT_SHOP

HAS_ONE

HAS_ONE

List of association types

HAS_MANY

HAS_MANY

Properties

$id

$id : integer

Type

integer — Object id

$id_shop_list

$id_shop_list : 

Type

$definition

$definition : array

Type

array — Contain object definition

$force_id

$force_id : \boolean,

Type

\boolean, — enable possibility to define an id before adding object

$id_lang

$id_lang : integer

Type

integer — lang id

$id_shop

$id_shop : 

Type

$get_shop_from_context

$get_shop_from_context : 

Type

$fieldsRequiredDatabase

$fieldsRequiredDatabase : 

Type

$table

$table : 

Type

$identifier

$identifier : 

Type

$fieldsRequired

$fieldsRequired : 

Type

$fieldsSize

$fieldsSize : 

Type

$fieldsValidate

$fieldsValidate : 

Type

$fieldsRequiredLang

$fieldsRequiredLang : 

Type

$fieldsSizeLang

$fieldsSizeLang : 

Type

$fieldsValidateLang

$fieldsValidateLang : 

Type

$tables

$tables : 

Type

$webserviceParameters

$webserviceParameters : array

Type

array — tables

$image_dir

$image_dir : string

Type

string — path to image directory. Used for image deletion.

$image_format

$image_format : string

Type

string — file type of image files. Used for image deletion.

$loaded_classes

$loaded_classes : 

Type

$def

$def : array

Type

array — Contain current object definition

$update_fields

$update_fields : array

Type

array — List of specific fields to update (all fields if null)

$db

$db : \Db

Type

\Db — An instance of the db in order to avoid calling Db::getInstance() thousands of time

$cache_objects

$cache_objects : boolean

Type

boolean — cache the objects in memory

Methods

getValidationRules()

getValidationRules(string  $class = __CLASS__) : array

Returns object validation rules (fields validity)

Parameters

string $class

Child class name for static use (optional)

Returns

array —

Validation rules (fields validity)

__construct()

__construct(integer  $id = null, integer  $id_lang = null, integer  $id_shop = null) 

Build object

Parameters

integer $id

Existing object id in order to load object (optional)

integer $id_lang

Required if object is multilingual (optional)

integer $id_shop

ID shop for objects with multishop on langs

getFields()

getFields() : array

Prepare fields for ObjectModel class (add, update) All fields are verified (pSQL, intval.

..)

Returns

array —

All object fields

getFieldsShop()

getFieldsShop() : array

Prepare fields for multishop Fields are not validated here, we considere they are already validated in getFields() method, this not the best solution but this is the only one possible for retro compatibility.

Returns

array —

All object fields

getFieldsLang()

getFieldsLang() : array

Prepare multilang fields

Returns

array

formatValue()

formatValue(mixed  $value, integer  $type,   $with_quotes = false,   $purify = true) 

Format a data

Parameters

mixed $value
integer $type
$with_quotes
$purify

save()

save(boolean  $null_values = false, boolean  $autodate = true) : boolean

Save current object to database (add or update)

Parameters

boolean $null_values
boolean $autodate

Returns

boolean —

Insertion result

add()

add(boolean  $autodate = true, boolean  $null_values = false) : boolean

Add current object to database

Parameters

boolean $autodate
boolean $null_values

Returns

boolean —

Insertion result

duplicateObject()

duplicateObject() : \new

Duplicate current object to database

Returns

\new —

object

update()

update(boolean  $null_values = false) : boolean

Update current object to database

Parameters

boolean $null_values

Returns

boolean —

Update result

delete()

delete() : boolean

Delete current object from database

Returns

boolean —

Deletion result

deleteSelection()

deleteSelection(array  $selection) : boolean

Delete several objects from database

Parameters

array $selection

Returns

boolean —

Deletion result

toggleStatus()

toggleStatus() : boolean

Toggle object status in database

Returns

boolean —

Update result

validateFields()

validateFields(boolean  $die = true, boolean  $error_return = false) : boolean|string

Check for fields validity before database interaction

Parameters

boolean $die
boolean $error_return

Returns

boolean|string

validateFieldsLang()

validateFieldsLang(boolean  $die = true, boolean  $error_return = false) : boolean|string

Check for multilingual fields validity before database interaction

Parameters

boolean $die
boolean $error_return

Returns

boolean|string

validateField()

validateField(string  $field, mixed  $value, integer  $id_lang = null,   $skip = array(),   $human_errors = false) : boolean|string

Validate a single field

Parameters

string $field

Field name

mixed $value

Field value

integer $id_lang
$skip
$human_errors

Returns

boolean|string

displayFieldName()

displayFieldName(  $field,   $class = __CLASS__,   $htmlentities = true, \Context  $context = null) 

Parameters

$field
$class
$htmlentities
\Context $context

validateControler()

validateControler(  $htmlentities = true) 

TODO: refactor rename all calls to this to validateController

Parameters

$htmlentities

validateController()

validateController(  $htmlentities = true) 

Parameters

$htmlentities

getWebserviceParameters()

getWebserviceParameters(  $ws_params_attribute_name = null) 

Parameters

$ws_params_attribute_name

getWebserviceObjectList()

getWebserviceObjectList(  $sql_join,   $sql_filter,   $sql_sort,   $sql_limit) 

Parameters

$sql_join
$sql_filter
$sql_sort
$sql_limit

validateFieldsRequiredDatabase()

validateFieldsRequiredDatabase(  $htmlentities = true) 

Parameters

$htmlentities

getFieldsRequiredDatabase()

getFieldsRequiredDatabase(  $all = false) 

Parameters

$all

cacheFieldsRequiredDatabase()

cacheFieldsRequiredDatabase(  $all = true) 

Parameters

$all

addFieldsRequiredDatabase()

addFieldsRequiredDatabase(  $fields) 

Parameters

$fields

clearCache()

clearCache(  $all = false) 

Parameters

$all

isAssociatedToShop()

isAssociatedToShop(integer  $id_shop = null) : boolean

Check if current object is associated to a shop

Parameters

integer $id_shop

Returns

boolean

associateTo()

associateTo(integer|array  $id_shops) : boolean

This function associate an item to its context

Parameters

integer|array $id_shops

Returns

boolean

getAssociatedShops()

getAssociatedShops() : array

Get the list of associated id_shop

Returns

array

duplicateShops()

duplicateShops(  $id) 

Parameters

$id

hasMultishopEntries()

hasMultishopEntries() : boolean

Check if there is more than one entries in associated shop table for current entity

Returns

boolean

isMultishop()

isMultishop() 

isMultiShopField()

isMultiShopField(  $field) 

Parameters

$field

isLangMultishop()

isLangMultishop() 

updateMultishopTable()

updateMultishopTable(string  $classname, array  $data, string  $where = '', string  $specific_where = '') : boolean

Update a table and splits the common datas and the shop datas

Parameters

string $classname
array $data
string $where
string $specific_where

Only executed for common table

Returns

boolean

deleteImage()

deleteImage(  $force_delete = false) : boolean

Delete images associated with the object

Parameters

$force_delete

Returns

boolean —

success

existsInDatabase()

existsInDatabase(integer  $id_entity, string  $table) : boolean

Specify if an ObjectModel is already in database

Parameters

integer $id_entity
string $table

Returns

boolean

isCurrentlyUsed()

isCurrentlyUsed(string  $table = null, boolean  $has_active_column = false) : boolean

This method is allow to know if a entity is currently used

Parameters

string $table

name of table linked to entity

boolean $has_active_column

true if the table has an active column

Returns

boolean

hydrate()

hydrate(array  $data, integer  $id_lang = null) 

Fill an object with given data. Data must be an array with this syntax: array(objProperty => value, objProperty2 => value, etc.)

Parameters

array $data
integer $id_lang

hydrateCollection()

hydrateCollection(string  $class, array  $datas, integer  $id_lang = null) : array

Fill (hydrate) a list of objects in order to get a collection of these objects

Parameters

string $class

Class of objects to hydrate

array $datas

List of data (multi-dimensional array)

integer $id_lang

Returns

array

getDefinition()

getDefinition(string  $class, string  $field = null) : array

Get object definition

Parameters

string $class

Name of object

string $field

Name of field if we want the definition of one field only

Returns

array

getFieldByLang()

getFieldByLang(  $field_name, null  $id_lang = null) : mixed

Return the field value for the specified language if the field is multilang, else the field value.

Parameters

$field_name
null $id_lang

Throws

\PrestaShopException

Returns

mixed

setFieldsToUpdate()

setFieldsToUpdate(array  $fields) 

Set a list of specific fields to update array(field1 => true, field2 => false, langfield1 => array(1 => true, 2 => false))

Parameters

array $fields

enableCache()

enableCache() 

disableCache()

disableCache() 

formatFields()

formatFields(integer  $type, integer  $id_lang = null) : array

Parameters

integer $type

FORMAT_COMMON or FORMAT_LANG or FORMAT_SHOP

integer $id_lang

If this parameter is given, only take lang fields

Returns

array

getTranslationsFields()

getTranslationsFields(  $fields_array) 

Parameters

$fields_array

makeTranslationFields()

makeTranslationFields(  $fields,   $fields_array,   $id_language) 

Parameters

$fields
$fields_array
$id_language

setDefinitionRetrocompatibility()

setDefinitionRetrocompatibility() 

Retrocompatibility for classes without $definition static Remove this in 1.6 !