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 Answer 1

4

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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