Constants

LEFT_JOIN

LEFT_JOIN

INNER_JOIN

INNER_JOIN

LEFT_OUTER_JOIN

LEFT_OUTER_JOIN

LANG_ALIAS

LANG_ALIAS

Properties

$classname

$classname : string

Type

string — Object class name

$id_lang

$id_lang : integer

Type

integer

$definition

$definition : array

Type

array — Object definition

$query

$query : \DbQuery

Type

\DbQuery

$results

$results : array

Type

array — Collection of objects in an array

$is_hydrated

$is_hydrated : boolean

Type

boolean — Is current collection already hydrated

$iterator

$iterator : integer

Type

integer — Collection iterator

$total

$total : integer

Type

integer — Total of elements for iteration

$page_number

$page_number : integer

Type

integer — Page number

$page_size

$page_size : integer

Type

integer — Size of a page

$fields

$fields : 

Type

$alias

$alias : 

Type

$alias_iterator

$alias_iterator : 

Type

$join_list

$join_list : 

Type

$association_definition

$association_definition : 

Type

Methods

__construct()

__construct(string  $classname, integer  $id_lang = null) 

Parameters

string $classname
integer $id_lang

join()

join(string  $association, string  $on = '', integer  $type = null) : \PrestaShopCollection

Join current entity to an associated entity

Parameters

string $association

Association name

string $on
integer $type

Returns

\PrestaShopCollection

where()

where(string  $field, string  $operator, mixed  $value,   $method = 'where') : \PrestaShopCollection

Add WHERE restriction on query

Parameters

string $field

Field name

string $operator

List of operators : =, !=, <>, <, <=, >, >=, like, notlike, regexp, notregexp

mixed $value
$method

Returns

\PrestaShopCollection

sqlWhere()

sqlWhere(string  $sql) : \PrestaShopCollection

Add WHERE restriction on query using real SQL syntax

Parameters

string $sql

Returns

\PrestaShopCollection

having()

having(string  $field, string  $operator, mixed  $value) : \PrestaShopCollection

Add HAVING restriction on query

Parameters

string $field

Field name

string $operator

List of operators : =, !=, <>, <, <=, >, >=, like, notlike, regexp, notregexp

mixed $value

Returns

\PrestaShopCollection

sqlHaving()

sqlHaving(string  $sql) : \PrestaShopCollection

Add HAVING restriction on query using real SQL syntax

Parameters

string $sql

Returns

\PrestaShopCollection

orderBy()

orderBy(string  $field, string  $order = 'asc') : \PrestaShopCollection

Add ORDER BY restriction on query

Parameters

string $field

Field name

string $order

asc|desc

Returns

\PrestaShopCollection

sqlOrderBy()

sqlOrderBy(string  $sql) : \PrestaShopCollection

Add ORDER BY restriction on query using real SQL syntax

Parameters

string $sql

Returns

\PrestaShopCollection

groupBy()

groupBy(string  $field) : \PrestaShopCollection

Add GROUP BY restriction on query

Parameters

string $field

Field name

Returns

\PrestaShopCollection

sqlGroupBy()

sqlGroupBy(string  $sql) : \PrestaShopCollection

Add GROUP BY restriction on query using real SQL syntax

Parameters

string $sql

Returns

\PrestaShopCollection

getAll()

getAll(boolean  $display_query = false) : \PrestaShopCollection

Launch sql query to create collection of objects

Parameters

boolean $display_query

If true, query will be displayed (for debug purpose)

Returns

\PrestaShopCollection

getFirst()

getFirst() : \ObjectModel

Retrieve the first result

Returns

\ObjectModel

getResults()

getResults() : array

Get results array

Returns

array

rewind()

rewind() 

This method is called when a foreach begin

current()

current() : \ObjectModel

Get current result

Returns

\ObjectModel

valid()

valid() : boolean

Check if there is a current result

Returns

boolean

key()

key() : integer

Get current result index

Returns

integer

next()

next() 

Go to next result

count()

count() : integer

Get total of results

Returns

integer

offsetExists()

offsetExists(  $offset) : boolean

Check if a result exist

Parameters

$offset

Returns

boolean

offsetGet()

offsetGet(  $offset) : \ObjectModel

Get a result by offset

Parameters

$offset

Returns

\ObjectModel

offsetSet()

offsetSet(  $offset,   $value) 

Add an element in the collection

Parameters

$offset
$value

offsetUnset()

offsetUnset(  $offset) 

Delete an element from the collection

Parameters

$offset

setPageNumber()

setPageNumber(integer  $page_number) : \PrestaShopCollection

Set the page number

Parameters

integer $page_number

Returns

\PrestaShopCollection

setPageSize()

setPageSize(integer  $page_size) : \PrestaShopCollection

Set the nuber of item per page

Parameters

integer $page_size

Returns

\PrestaShopCollection

getDefinition()

getDefinition(string  $association) : array

Get definition of an association

Parameters

string $association

Returns

array

parseFields()

parseFields(string  $str) : string

Parse all fields with {field} syntax in a string

Parameters

string $str

Returns

string

parseField()

parseField(string  $field) : string

Replace a field with its SQL version (E.g. manufacturer.name with a2.name)

Parameters

string $field

Field name

Returns

string

formatValue()

formatValue(mixed  $value, string  $field) : mixed

Format a value with the type of the given field

Parameters

mixed $value
string $field

Field name

Returns

mixed

getFieldInfo()

getFieldInfo(string  $field) : array

Obtain some information on a field (alias, name, type, etc.)

Parameters

string $field

Field name

Returns

array

generateAlias()

generateAlias(string  $association = '') : string

Generate uniq alias from association name

Parameters

string $association

Use empty association for alias on current table

Returns

string