fetching taxonomy tree from database from query

214 Views Asked by At

I add a vocablary named "product sub categories" and I want to fetch the whole tree structure from datebase through query? Can anybody can help me?

1

There are 1 best solutions below

3
On

You can use the Drupal API taxonomy_get_tree function, you only need the vocabulary id.

$taxonomyTree = taxonomy_get_tree($vid);

If you are using Drupal 7, you can use taxonomy_vocabulary_machine_name_load to get the vocabulary object by its name.

$vocabularyObject = taxonomy_vocabulary_machine_name_load("product sub categories");