|
| 1 | +--- |
| 2 | +month_change: false |
| 3 | +editions: |
| 4 | + - lts-update |
| 5 | + - commerce |
| 6 | +--- |
| 7 | + |
| 8 | +# Discounts Search Criterion reference |
| 9 | + |
| 10 | +Search Criteria are found in the `Ibexa\Contracts\Discounts\Value\Query\Criterion` namespace, implementing the [CriterionInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionConfiguration-Query-CriterionInterface.html) interface: |
| 11 | + |
| 12 | +| Criterion | Description | |
| 13 | +|---|---| |
| 14 | +| [CreatedAtCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-CreatedAtCriterion.html) | Find discounts with given creation date| |
| 15 | +| [CreatorCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-CreatorCriterion.html) | Find discounts created by specific users| |
| 16 | +| [EndDateCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-EndDateCriterion.html) | Find discounts by their end date. For permanent discounts, the end date is set to `null` | |
| 17 | +| [IdentifierCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-IdentifierCriterion.html) | Find discounts by their identifier | |
| 18 | +| [IsEnabledCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-IsEnabledCriterion.html) | Find discounts by their status| |
| 19 | +| [LogicalAnd](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-LogicalAnd.html) | Composite criterion to group multiple criterions using the AND condition | |
| 20 | +| [LogicalOr](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-LogicalOr.html) | Composite criterion to group multiple criterions using the OR condition | |
| 21 | +| [NameCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-NameCriterion.html) | Find discounts by their name | |
| 22 | +| [PriorityCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-PriorityCriterion.html) | Find discounts by their priority | |
| 23 | +| [StartDateCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-StartDateCriterion.html) | Find discounts with given start date| |
| 24 | +| [TypeCriterion](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-Criterion-TypeCriterion.html) | Find cart or catalog discounts by using constants from the [DiscountType](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-DiscountType.html) class| |
| 25 | + |
| 26 | +You can use the [FieldValueCriterion's constants](/api/php_api/php_api_reference/classes/Ibexa-Contracts-CoreSearch-Values-Query-Criterion-FieldValueCriterion.html#constants) like `FieldValueCriterion::COMPARISON_CONTAINS` or `FieldValueCriterion::COMPARISON_STARTS_WITH` to specify the operator for the condition. |
| 27 | + |
| 28 | +Use the `limit` and `offset` properties of [DiscountQuery](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Query-DiscountQuery.html#constants) to limit the number of results and implement pagination. |
| 29 | + |
| 30 | +The following example shows how you can use the criteria to find all the currently active discounts: |
| 31 | + |
| 32 | +```php hl_lines="13-20" |
| 33 | +[[= include_file('code_samples/discounts/src/Query/Search.php') =]] |
| 34 | +``` |
| 35 | + |
| 36 | +The criteria limit the result set to discounts matching all of the conditions listed below: |
| 37 | + |
| 38 | +- discount must be enabled |
| 39 | +- discount start date is not after the current date |
| 40 | +- discount end date is not before the current date or is not specified |
0 commit comments