开发者

Drupal 7 Taxonomy: Find TID by custom field value

开发者 https://www.devze.com 2023-03-05 23:26 出处:网络
// Application Drupal 7 // Problem Background My website imports product data from a CSV file. I have a module that parses the file and creates appropriate nodes. In the CSV file, product category

// Application

Drupal 7

// Problem Background

My website imports product data from a CSV file. I have a module that parses the file and creates appropriate nodes. In the CSV file, product category is given by category ID, which are different than Taxonomy Term IDs I have for the product categories in Drupal. I have created a custom field in my Taxonomy Vocabulary ("category_id") to link Drupal categories to imported category IDs.

When creating a node during import, I need "tid" (Taxonomy Term ID) to assign a node to a Taxonomy Term.

// The Question

Ho开发者_开发技巧w can I find Taxonomy Term ID ("tid"), knowing the value of a custom Taxonomy field?


Your custom taxonomy field ("category_id") creates a table field_data_field_category_id which should have an entity_id column/field which is your tid.


If you have command line Drush access, you could do:

drush php-eval '$tax=taxonomy_vocabulary_machine_name_load("main_site_structure");echo $tax->vid;'
0

精彩评论

暂无评论...
验证码 换一张
取 消