Query according to field condition in DRUPAL 8

22
April

Query according to field condition in DRUPAL 8
By: Anonymous | Published On: Wed, 04/22/2020 - 22:13

Code to query for getting node according to field condition in DRUPAL 8

$query = \Drupal::entityQuery('node')
  ->condition('status', NODE_PUBLISHED)
  ->condition('type', 'custom_type');
$and = $query->andConditionGroup();
$and->condition('custom_taxonomy', 2);
$query->condition($and);
$and = $query->andConditionGroup();
$and->condition('custom_taxonomy', 8);
$query->condition($and);
$result = $query->execute();

Comments

Need Help ?