0

Im currently using Drupal::entityQuery() to build a list of node.

I need to be able to query only contentEntities that have a specific translation not published. I struggle because I don't know how to make a condition on an entity translated field/property.

to sum up: How to query all nodes that have 'de' translation AND which their 'de' translation are not published?

Is there a way to do it with Drupal::entityQuery() or should I directly go with altering the query with QueryInterface::addTag() where I would be able to customize the query?

1

This should do what you want. Note that the id's will load the default language, you will need to use getTranslation(langCode) to get the translated node.

$query = \Drupal::entityQuery('node');
$query->condition('status', 0);
$query->condition('type', YOUR_TYPE);
$query->condition('langcode', 'de');
$ids = $query->execute();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.