Skip to content

Shopping list search sort clauses reference

The sort clauses are in the Ibexa\Contracts\ShoppingList\Value\Query\SortClause namespace.

Sort clause Description
CreatedAt Sort by creation date
IsDefault Sort by being default or not
Name Sort by name
UpdatedAt Sort by last modification date

The following example returns all the shopping lists available to the current user. The returned shopping list are sorted with the default shopping list on top, followed by the rest sorted by their name.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
use Ibexa\Contracts\ShoppingList\Value\Query\SortClause\IsDefault;
use Ibexa\Contracts\ShoppingList\Value\Query\SortClause\Name;
use Ibexa\Contracts\ShoppingList\Value\ShoppingListQuery;

/** @var \Ibexa\Contracts\ShoppingList\ShoppingListServiceInterface $shoppingListService */
$lists = $shoppingListService->findShoppingLists(
    new ShoppingListQuery(
        null,
        [
            new IsDefault(IsDefault::SORT_DESC),
            new Name(),
        ]
    )
);

For more information about shopping lists search, see List and search shopping lists.