-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathSearch.php
More file actions
29 lines (24 loc) · 967 Bytes
/
Copy pathSearch.php
File metadata and controls
29 lines (24 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
declare(strict_types=1);
use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;
use Ibexa\Contracts\Discounts\Value\Query\Criterion;
use Ibexa\Contracts\Discounts\Value\Query\DiscountQuery;
use Ibexa\Contracts\Discounts\Value\Query\SortClause;
$now = new DateTimeImmutable();
$query = new DiscountQuery(
new Criterion\LogicalAnd(
new Criterion\IsEnabledCriterion(),
new Criterion\StartDateCriterion($now, FieldValueCriterion::COMPARISON_LTE),
new Criterion\LogicalOr(
new Criterion\EndDateCriterion($now, FieldValueCriterion::COMPARISON_GTE),
new Criterion\EndDateCriterion(null, FieldValueCriterion::COMPARISON_EQ)
),
),
[
new SortClause\Type(),
new SortClause\Priority(),
new SortClause\CreatedAt(),
]
);
/** @var \Ibexa\Contracts\Discounts\DiscountServiceInterface $discountService */
$results = $discountService->findDiscounts($query);