I've been experimenting with SearchCriteriaBuilder but I can't seem to get the syntax right to apply multiple sort.
I've tried this
$this->searchCriteriaBuilder->addFilter(EntryInterface::STATUS, 1, 'eq');
$sort = [];
$sort[] = $this->sortOrder->setField(EntryInterface::COUNTRY)
->setDirection(SortOrder::SORT_ASC);
$sort[] = $this->sortOrder->setField(EntryInterface::SORT)
->setDirection(SortOrder::SORT_ASC);
$this->searchCriteriaBuilder->setSortOrders($sort);
$searchCriteria = $this->searchCriteriaBuilder->create();
return $this->entryRepositoryInterface->getList($searchCriteria)->getItems();
And this...
$this->searchCriteriaBuilder->addFilter(EntryInterface::STATUS, 1, 'eq');
$sortOne = $this->sortOrder->setField(EntryInterface::COUNTRY)
->setDirection(SortOrder::SORT_ASC);
$sortTwo = $this->sortOrder->setField(EntryInterface::SORT)
->setDirection(SortOrder::SORT_ASC);
$this->searchCriteriaBuilder->setSortOrders([$sortOne, $sortTwo]);
$searchCriteria = $this->searchCriteriaBuilder->create();
return $this->entryRepositoryInterface->getList($searchCriteria)->getItems();
One more I tried
[...]
$this->searchCriteriaBuilder->setSortOrders([$sortOne]);
$this->searchCriteriaBuilder->setSortOrders([$sortTwo]);
[...]
But only one sort applies.
I've checked the docs and I'm still unsure.
Is it possible to apply multiple sorts?