0

I created a content type named product. How can I retrive all node of such content type using the entityQuery method?

I tried with this, but it doesn't works:

$ids = \Drupal::entityQuery('product')
  ->execute();

$products = \Drupal::entityManager()
  ->getStorage('node')
  ->loadMultiple($ids);
1

This is how we do this:

$ids = \Drupal::entityQuery('node')
  ->condition('type', 'product')
  ->execute();

$products = \Drupal::entityManager()
  ->getStorage('node')
  ->loadMultiple($ids);

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.