0

I want to retrieve a taxonomy term using this line:

$term = $this->entityTypeManager->getStorage('taxonomy_term')
        ->loadByProperties(['myfield' => 'mytext']);

How can I rather use the 'LIKE' operator we have in SQL, so that in case the 'myfield' contains a text and not a string in the database, it still works? Thanks for your help

1 Answer 1

1

I found the answer..I had to use the entity query then load term:

$result = \Drupal::entityQuery('taxonomy_term')
        ->condition('myfield', 'mytext', 'LIKE')
        ->execute();

$term = \Drupal::entityTypeManager()
        ->getStorage('taxonomy_term')
        ->loadMultiple($result); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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