Entity query not working with multiple languages.

Created on 6 November 2019, over 4 years ago
Updated 28 June 2023, about 1 year ago

Hello,

We have a multilingual website working with Domain module. Multiple languages are allowed for a site, for instance we can display nodes in EN/EN-GB/EN-US language in a specific page.

Problem/Motivation

It is not possible use Entity Query with multiple languages. There is a langcode parameter in some functions, but it is always a string :

I'm not able to use QueryInterface::sort() to sort my nodes with several languages or Condition::notExists to work with multiple languages.
Currently I have to do a custom select to retrieve correctly my nodes.

Proposed resolution

Can we find a way to be able to pass an array to the functions above? Or do you have another solution for this?

Thanks for your help.

πŸ› Bug report
Status

Active

Version

9.5

Component
EntityΒ  β†’

Last updated about 21 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine ankondrat4

    Hello.

    How we can use entityQuery on multilanguage sites for getting nodes/translations by langcode?
    For example, I have some code:

    $query = $this->entityTypeManager->getStorage('node')->getQuery()
          ->condition('type', $types, 'IN')
          ->condition('status', 1)
          ->condition('langcode', $language)
          ->sort('created', 'DESC')
          ->pager($ipp);
    

    But it gets only nodes that created on $language and doesn't have any translations OR nodes that has last translation to $language.
    I confused) How I can get all nodes that has created on $language or has translation to $language by use entityQuery?

Production build 0.69.0 2024