I have a vocabulary with a field "legacy_id" which is a primary key another related system. I am building a routine to update the data in the drupal system based on changes in the related system. Other then hitting the DB directly, is there a way to retrieve the tid or the entire term from the field?
You can use EntityFieldQuery,
Here is the sample code,
$query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'taxonomy_term') ->propertyCondition('vid', 1) // change 2 to any vocabulary ID ->fieldCondition('field_test', 'value', 'test'); $terms = $query->execute();
First param to fieldCondition is the field name, second one will be the column name for example for text fields column name is value and for term reference field tid, then the final one is to specify the value. Hope this helps.