Drupal Answers Asked by Sivaji on October 9, 2020
The terms returned contain depth as a Term object attribute.
$vocabulary = 'category';
$entity_manager = Drupal::entityTypeManager();
$entity_storage = $entity_manager->getStorage('taxonomy_term');
$terms = $entity_storage->loadTree($vocabulary);
However, when I try to load terms by depth, I get an error.
$entity_manager = Drupal::entityTypeManager();
$entity_storage = $entity_manager->getStorage('taxonomy_term');
$terms = $entity_storage->loadByProperties([
'vid' => $vocabulary,
'depth' => 0,
]);
The error is the following.
Uncaught PHP Exception DrupalCoreEntityQueryQueryException: "’depth’ not found
What is the way to find attributes I can use on loadByProperties()
?
What is the way to find attributes I can use on loadByProperties()?
I guess with Devel's Kint, loading one and then looking at the "iterator contents" tab
$entity_manager = Drupal::entityTypeManager();
$entity_storage = $entity_manager->getStorage('taxonomy_term');
$term = $entity_storage->load(1);
kint($term);
Correct answer by No Sssweat on October 9, 2020
1 Asked on October 26, 2021
1 Asked on October 26, 2021 by sbastien-gicquel
0 Asked on October 26, 2021 by matoeil
1 Asked on October 26, 2021 by turpentyne
1 Asked on October 26, 2021
0 Asked on October 26, 2021 by alexandre
1 Asked on October 26, 2021 by pedro-tentugal
1 Asked on October 26, 2021 by aroopk
2 Asked on October 26, 2021 by benjen
1 Asked on October 26, 2021 by baud
0 Asked on October 26, 2021
1 Asked on October 26, 2021 by nils-riedemann
1 Asked on October 26, 2021 by benn-moffat
4 Asked on October 26, 2021 by nielsv
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP