0

I have a custom module which generates an API, I want the API to filter content based on a node reference field. How do I pass the field field_author(Entity Reference from another content type) field as an argument to loadByProperties?

public function get() {

$entities = \Drupal::entityTypeManager()->getStorage('node')- 
>loadByProperties(['field_author' => 'Holmes']);

}
1

Thanks to 4k4

I modified my code to

    $entities = \Drupal::entityTypeManager()->getStorage('node')- 
    >loadByProperties(['field_author' => '469']); 

Where 469 is the nid of my Referenced Node

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.