Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
CriteriaInterface Interface Reference
Inheritance diagram for CriteriaInterface:
StockCriteriaInterface StockItemCriteriaInterface StockStatusCriteriaInterface AbstractCriteria StockCriteria StockItemCriteria StockStatusCriteria StockItemCriteria StockStatusCriteria StockCriteria Sample

Public Member Functions

 getMapperInterfaceName ()
 
 addField ($field, $alias=null)
 
 addFilter ($name, $field, $condition=null, $type='and')
 
 addOrder ($field, $direction=self::SORT_ORDER_DESC, $unShift=false)
 
 setLimit ($offset, $size)
 
 removeField ($field, $isAlias=false)
 
 removeAllFields ()
 
 removeFilter ($name)
 
 removeAllFilters ()
 
 getCriteriaList ()
 
 getFilters ()
 
 getOrders ()
 
 getLimit ()
 
 getPart ($name, $default=null)
 
 toArray ()
 
 reset ()
 

Data Fields

const PART_FIELDS = 'fields'
 
const PART_FILTERS = 'filters'
 
const PART_ORDERS = 'orders'
 
const PART_CRITERIA_LIST = 'criteria_list'
 
const PART_LIMIT = 'limit'
 
const SORT_ORDER_ASC = 'ASC'
 
const SORT_ORDER_DESC = 'DESC'
 

Detailed Description

Interface CriteriaInterface

Definition at line 11 of file CriteriaInterface.php.

Member Function Documentation

◆ addField()

addField (   $field,
  $alias = null 
)

Add field to select

Parameters
string | array$field
string | null$alias
Returns
void

Implemented in AbstractCriteria.

◆ addFilter()

addFilter (   $name,
  $field,
  $condition = null,
  $type = 'and' 
)

Add field filter to collection

If $condition integer or string - exact value will be filtered ('eq' condition)

If $condition is array - one of the following structures is expected:

  • ["from" => $fromValue, "to" => $toValue]
  • ["eq" => $equalValue]
  • ["neq" => $notEqualValue]
  • ["like" => $likeValue]
  • ["in" => [$inValues]]
  • ["nin" => [$notInValues]]
  • ["notnull" => $valueIsNotNull]
  • ["null" => $valueIsNull]
  • ["moreq" => $moreOrEqualValue]
  • ["gt" => $greaterValue]
  • ["lt" => $lessValue]
  • ["gteq" => $greaterOrEqualValue]
  • ["lteq" => $lessOrEqualValue]
  • ["finset" => $valueInSet]
If non matched - sequential parallel arrays are expected and OR conditions
will be built using above mentioned structure.
Example:
$field = ['age', 'name'];
$condition = [42, ['like' => 'Mage']];
$type = 'or';

The above would find where age equal to 42 OR name like Mage%.

Parameters
string$name
string | array$field
string | int | array$condition
string$type
Exceptions

Implemented in AbstractCriteria.

◆ addOrder()

addOrder (   $field,
  $direction = self::SORT_ORDER_DESC,
  $unShift = false 
)

self::setOrder() alias

Parameters
string$field
string$direction
bool$unShift
Returns
void

Implemented in AbstractCriteria.

◆ getCriteriaList()

getCriteriaList ( )

Get Criteria objects added to current Composite Criteria

Returns
\Magento\Framework\Api\CriteriaInterface[]

Implemented in AbstractCriteria.

◆ getFilters()

getFilters ( )

Get list of filters

Returns
string[]

Implemented in AbstractCriteria.

◆ getLimit()

getLimit ( )

Get limit (['offset', 'page'])

Returns
string[]

Implemented in AbstractCriteria.

◆ getMapperInterfaceName()

getMapperInterfaceName ( )

Get associated Mapper Interface name

Returns
string

Implemented in AbstractCriteria.

◆ getOrders()

getOrders ( )

Get ordering criteria

Returns
string[]

Implemented in AbstractCriteria.

◆ getPart()

getPart (   $name,
  $default = null 
)

Retrieve criteria part

Parameters
string$name
mixed$default
Returns
mixed

Implemented in AbstractCriteria.

◆ removeAllFields()

removeAllFields ( )

Removes all fields from select

Returns
void

Implemented in AbstractCriteria.

◆ removeAllFilters()

removeAllFilters ( )

Removes all filters

Returns
void

Implemented in AbstractCriteria.

◆ removeField()

removeField (   $field,
  $isAlias = false 
)

Removes field from select

Parameters
string | null$field
bool$isAliasAlias identifier
Returns
void

Implemented in AbstractCriteria.

◆ removeFilter()

removeFilter (   $name)

Removes filter by name

Parameters
string$name
Returns
void

Implemented in AbstractCriteria.

◆ reset()

reset ( )

Reset criteria

Returns
void

Implemented in AbstractCriteria.

◆ setLimit()

setLimit (   $offset,
  $size 
)

Set Query limit

Parameters
int$offset
int$size
Returns
void

Implemented in AbstractCriteria.

◆ toArray()

toArray ( )

Return all criteria parts as array

Returns
array

Implemented in AbstractCriteria.

Field Documentation

◆ PART_CRITERIA_LIST

const PART_CRITERIA_LIST = 'criteria_list'

Definition at line 16 of file CriteriaInterface.php.

◆ PART_FIELDS

const PART_FIELDS = 'fields'

Definition at line 13 of file CriteriaInterface.php.

◆ PART_FILTERS

const PART_FILTERS = 'filters'

Definition at line 14 of file CriteriaInterface.php.

◆ PART_LIMIT

const PART_LIMIT = 'limit'

Definition at line 17 of file CriteriaInterface.php.

◆ PART_ORDERS

const PART_ORDERS = 'orders'

Definition at line 15 of file CriteriaInterface.php.

◆ SORT_ORDER_ASC

const SORT_ORDER_ASC = 'ASC'

Definition at line 19 of file CriteriaInterface.php.

◆ SORT_ORDER_DESC

const SORT_ORDER_DESC = 'DESC'

Definition at line 20 of file CriteriaInterface.php.


The documentation for this interface was generated from the following file: