I have an entity line_item with the following fields:
- id
- uid (entity reference)
- product (entity reference)
- ...
I would like to get all distinct products (product ids) for a specific user.
I tried with entity query:
$query = $this->entity_query->get('line_item');
$query->condition('uid.entity.name', $username);
$entity_ids = $query->execute();
Unfortunately this results in all line_items from the given user, with multiple times the same product. But what I am interested in is just getting all different products for the given user.