Skip to main content

Class: default

data/Criteria.default

Constructors

constructor

new default(page?, limit?)

Parameters

NameTypeDefault value
pagenull | numberdefaultPage
limitnull | numberdefaultLimit

Defined in

packages/admin-sdk/src/data/Criteria.ts:202

Properties

page

page: null | number

Defined in

packages/admin-sdk/src/data/Criteria.ts:172


limit

limit: null | number

Defined in

packages/admin-sdk/src/data/Criteria.ts:174


term

term: null | string

Defined in

packages/admin-sdk/src/data/Criteria.ts:176


filters

filters: SingleFilter[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:178


ids

ids: string[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:180


queries

queries: Query[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:182


associations

associations: Association[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:184


postFilter

postFilter: SingleFilter[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:186


sortings

sortings: Sorting[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:188


aggregations

aggregations: Aggregation[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:190


grouping

grouping: string[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:192


fields

fields: string[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:194


groupFields

groupFields: string[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:196


totalCountMode

totalCountMode: null | TotalCountMode

Defined in

packages/admin-sdk/src/data/Criteria.ts:198


includes

includes: null | Include

Defined in

packages/admin-sdk/src/data/Criteria.ts:200

Methods

parse

parse(): RequestParams

Parses the current criteria and generates an object which can be provided to the api

Returns

RequestParams

Defined in

packages/admin-sdk/src/data/Criteria.ts:227


setIds

setIds(ids): default

Allows to provide a list of ids which are used as a filter

Parameters

NameType
idsstring[]

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:288


setTotalCountMode

setTotalCountMode(mode): default

Allows to configure the total value of a search result. 0 - no total count will be selected. Should be used if no pagination required (fastest) 1 - exact total count will be selected. Should be used if an exact pagination is required (slow) 2 - fetches limit * 5 + 1. Should be used if pagination can work with "next page exists" (fast)

Parameters

NameType
modeTotalCountMode

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:299


setPage

setPage(page): default

Parameters

NameType
pagenumber

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:308


setLimit

setLimit(limit): default

Parameters

NameType
limitnumber

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:313


setTerm

setTerm(term): default

Parameters

NameType
termstring

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:318


addFilter

addFilter(filter): default

Parameters

NameType
filterSingleFilter

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:323


addIncludes

addIncludes(include): default

Parameters

NameType
includeInclude

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:329


addPostFilter

addPostFilter(filter): default

Adds the provided filter as post filter. Post filter will be considered for the documents query but not for the aggregations.

Parameters

NameType
filterSingleFilter

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:348


addSorting

addSorting(sorting): default

Allows to add different sortings for the criteria, to sort the entity result.

Parameters

NameType
sortingSorting

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:356


addQuery

addQuery(filter, score, scoreField?): default

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Query\ScoreQuery. These queries are used to search for documents and score them with a ranking

Parameters

NameTypeDefault value
filterSingleFilterundefined
scorenumberundefined
scoreFieldnull | stringnull

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:365


addGroupField

addGroupField(groupField): default

Parameters

NameType
groupFieldstring

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:380


addGrouping

addGrouping(field): default

Allows grouping the result by a specific field

Parameters

NameType
fieldstring

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:388


addFields

addFields(...field): default

Allows loading partial fields for the result.

Parameters

NameType
...fieldstring[]

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:397


addAggregation

addAggregation(aggregation): default

Parameters

NameType
aggregationAggregation

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:406


addAssociation

addAssociation(path): default

Ensures that a criterion is created for each segment of the passed path. Existing Criteria objects are not overwritten. Returns the own instance

Parameters

NameType
pathstring

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:416


getAssociation

getAssociation(path): default

Ensures that a criterion is created for each segment of the passed path. Returns the criteria instance of the last path segment

Parameters

NameType
pathstring

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:433


getAssociationCriteria

getAssociationCriteria(part): null | default

Parameters

NameType
partstring

Returns

null | default

Defined in

packages/admin-sdk/src/data/Criteria.ts:453


getLimit

getLimit(): number

Returns

number

Defined in

packages/admin-sdk/src/data/Criteria.ts:465


getPage

getPage(): number

Returns

number

Defined in

packages/admin-sdk/src/data/Criteria.ts:469


getCriteriaData

getCriteriaData(): Object

Returns

Object

NameType
pagenull | number
limitnull | number
termnull | string
filtersSingleFilter[]
idsstring[]
queriesQuery[]
associationsAssociation[]
postFilterSingleFilter[]
sortingsSorting[]
aggregationsAggregation[]
groupingstring[]
fieldsstring[]
groupFieldsstring[]
totalCountModenull | TotalCountMode
includesnull | Include

Defined in

packages/admin-sdk/src/data/Criteria.ts:473


hasAssociation

hasAssociation(property): boolean

Parameters

NameType
propertystring

Returns

boolean

Defined in

packages/admin-sdk/src/data/Criteria.ts:509


resetSorting

resetSorting(): void

Resets the sorting parameter

Returns

void

Defined in

packages/admin-sdk/src/data/Criteria.ts:518


fromCriteria

Static fromCriteria(criteria): default

Parameters

NameType
criteriadefault

Returns

default

Defined in

packages/admin-sdk/src/data/Criteria.ts:220


avg

Static avg(name, field): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\AvgAggregation Allows to calculate the avg value for the provided field

Parameters

NameType
namestring
fieldstring

Returns

Object

NameType
type"avg"
namestring
fieldstring

Defined in

packages/admin-sdk/src/data/Criteria.ts:526


count

Static count(name, field): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\CountAggregation Allows to calculate the count value for the provided field

Parameters

NameType
namestring
fieldstring

Returns

Object

NameType
type"count"
namestring
fieldstring

Defined in

packages/admin-sdk/src/data/Criteria.ts:534


max

Static max(name, field): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\MaxAggregation Allows to calculate the max value for the provided field

Parameters

NameType
namestring
fieldstring

Returns

Object

NameType
type"max"
namestring
fieldstring

Defined in

packages/admin-sdk/src/data/Criteria.ts:542


min

Static min(name, field): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\MinAggregation Allows to calculate the min value for the provided field

Parameters

NameType
namestring
fieldstring

Returns

Object

NameType
type"min"
namestring
fieldstring

Defined in

packages/admin-sdk/src/data/Criteria.ts:550


stats

Static stats(name, field): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\StatsAggregation Allows to calculate the sum, max, min, avg, count values for the provided field

Parameters

NameType
namestring
fieldstring

Returns

Object

NameType
type"stats"
namestring
fieldstring

Defined in

packages/admin-sdk/src/data/Criteria.ts:558


sum

Static sum(name, field): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Metric\SumAggregation Allows to calculate the sum value for the provided field

Parameters

NameType
namestring
fieldstring

Returns

Object

NameType
type"sum"
namestring
fieldstring

Defined in

packages/admin-sdk/src/data/Criteria.ts:566


terms

Static terms(name, field, limit?, sort?, aggregation?): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Bucket\TermsAggregation Allows to fetch term buckets for the provided field

Parameters

NameTypeDefault value
namestringundefined
fieldstringundefined
limitnull | numbernull
sortnull | Sortingnull
aggregationnull | Aggregationnull

Returns

Object

NameType
type"terms"
namestring
fieldstring
limitnull | number
sortnull | Sorting
aggregationnull | Aggregation

Defined in

packages/admin-sdk/src/data/Criteria.ts:574


filter

Static filter(name, filter, aggregation): Filter

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Bucket\FilterAggregation Allows to filter an aggregation result

Parameters

NameType
namestring
filterSingleFilter[]
aggregationAggregation[]

Returns

Filter

Defined in

packages/admin-sdk/src/data/Criteria.ts:588


histogram

Static histogram(name, field, interval, format, aggregation, timeZone): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Aggregation\Bucket\DateHistogramAggregation Allows to fetch date buckets for the provided date interval

Parameters

NameType
namestring
fieldstring
intervalnull | string
formatnull | string
aggregationnull | Aggregation
timeZonenull | string

Returns

Object

NameType
type"histogram"
namestring
fieldstring
intervalnull | string
formatnull | string
aggregationnull | Aggregation
timeZonenull | string

Defined in

packages/admin-sdk/src/data/Criteria.ts:596


sort

Static sort(field, order?, naturalSorting?): Sorting

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting. Allows to sort the documents by the provided field

Parameters

NameTypeDefault value
fieldstringundefined
order"ASC" | "DESC"'ASC'
naturalSortingbooleanfalse

Returns

Sorting

Defined in

packages/admin-sdk/src/data/Criteria.ts:611


naturalSorting

Static naturalSorting(field, order?): Sorting

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting. Allows to sort the documents by the provided field naturally

Parameters

NameTypeDefault value
fieldstringundefined
order"ASC" | "DESC"'ASC'

Returns

Sorting

Defined in

packages/admin-sdk/src/data/Criteria.ts:619


countSorting

Static countSorting(field, order?): Sorting

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\CountSorting. Allows to sort the documents by counting associations via the provided field

Sql representation: ORDER BY COUNT({field}) {order}

Parameters

NameTypeDefault value
fieldstringundefined
order"ASC" | "DESC"'ASC'

Returns

Sorting

Defined in

packages/admin-sdk/src/data/Criteria.ts:629


contains

Static contains(field, value): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter. This allows to filter documents where the value are contained in the provided field.

Sql representation: {field} LIKE %{value}%

Parameters

NameType
fieldstring
valuestring

Returns

Object

NameType
type"contains"
fieldstring
valuestring

Defined in

packages/admin-sdk/src/data/Criteria.ts:639


prefix

Static prefix(field, value): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\PrefixFilter. This allows to filter documents where the value marks the beginning of the provided field.

Sql representation: {field} LIKE {value}%

Parameters

NameType
fieldstring
valuestring

Returns

Object

NameType
type"prefix"
fieldstring
valuestring

Defined in

packages/admin-sdk/src/data/Criteria.ts:649


suffix

Static suffix(field, value): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\SuffixFilter. This allows to filter documents where the value marks the end of the provided field.

Sql representation: {field} LIKE %{value}

Parameters

NameType
fieldstring
valuestring

Returns

Object

NameType
type"suffix"
fieldstring
valuestring

Defined in

packages/admin-sdk/src/data/Criteria.ts:659


equalsAny

Static equalsAny(field, value): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter. This allows to filter documents where the field matches one of the provided values

Sql representation: {field} IN ({value}, {value})

Parameters

NameType
fieldstring
value(null | string | number | boolean)[]

Returns

Object

NameType
type"equalsAny"
fieldstring
valuestring

Defined in

packages/admin-sdk/src/data/Criteria.ts:669


range

Static range(field, range): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\RangeFilter. This allows to filter documents where the field matches a defined range

Sql representation: {field} >= {value}, {field} <= {value}, ...

Parameters

NameType
fieldstring
rangeObject
range.lte?string
range.lt?string
range.gte?string
range.gt?string

Returns

Object

NameType
type"range"
fieldstring
parameters{ lte?: string ; lt?: string ; gte?: string ; gt?: string }
parameters.lte?string
parameters.lt?string
parameters.gte?string
parameters.gt?string

Defined in

packages/admin-sdk/src/data/Criteria.ts:679


equals

Static equals(field, value): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter. This allows to filter documents where the field matches a defined range

Sql representation: {field} = {value}

Parameters

NameType
fieldstring
valuenull | string | number | boolean

Returns

Object

NameType
type"equals"
fieldstring
valuenull | string | number | boolean

Defined in

packages/admin-sdk/src/data/Criteria.ts:689


not

Static not(operator, queries?): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\NotFilter. This allows to filter documents which not matches for the provided filters All above listed queries can be provided (equals, equalsAny, range, contains)

Sql representation: NOT({query} {operator} {query} {operator} {query})

Parameters

NameTypeDefault valueDescription
operator"and" | "AND" | "or" | "OR"undefinedand/or
queriesSingleFilter[][]

Returns

Object

NameType
type"not"
operator"and" | "AND" | "or" | "OR"
queriesSingleFilter[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:705


multi

Static multi(operator, queries?): Object

See

\Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\NotFilter. This allows to filter documents which matches for the provided filters All above listed queries can be provided (equals, equalsAny, range, contains)

Sql representation: ({query} {operator} {query} {operator} {query})

Parameters

NameTypeDefault valueDescription
operator"and" | "AND" | "or" | "OR"undefinedand/or
queriesSingleFilter[][]

Returns

Object

NameType
type"multi"
operator"and" | "AND" | "or" | "OR"
queriesSingleFilter[]

Defined in

packages/admin-sdk/src/data/Criteria.ts:721