I'm using ConfigEntity and on this Entity, there is a boolean Field (checkbox) called "Published".

Now I want to load all Entities with field Published = 1

Do you know how I can do that?

P.s. To load all Entities I'm using this line below:

$myEntities = \Drupal::entityTypeManager()->getStorage('my_entities')->loadMultiple();

If there is another best command, please let me know.

Thank you so much.



$entity_manager = \Drupal::entityTypeManager();
$entity_storage = $entity_manager->getStorage('entity_name_id');
$entitys_published = $entity_storage->loadByProperties([
  'status' => 1, // published
  • Thanks. I tried with but it didn't work for me – RenatoG Aug 21 '20 at 13:38
  • @RenatoGonçalves humm, try instead with 'published' => 1, although I doubt this is correct. – No Sssweat Aug 21 '20 at 13:52
  • If not, check both with => 0, maybe there aren't any published? – No Sssweat Aug 21 '20 at 13:53

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.