Last active
October 27, 2015 07:13
-
-
Save algotrader-dotcom/0d67b73cf10a4d4838f9 to your computer and use it in GitHub Desktop.
Drupal 7 : Update taxonomy term programmatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define('DRUPAL_ROOT', '/home/vhosts/domain.com'); | |
| require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; | |
| drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); | |
| require_once( DRUPAL_ROOT . '/sites/all/libraries/simplehtmldom/simple_html_dom.php'); | |
| include("phpcrawler/libs/PHPCrawler.class.php"); | |
| set_time_limit(0); | |
| $vid = 10; // Category | |
| if ($terms = taxonomy_get_tree($vid)) { | |
| foreach ($terms as $term) { | |
| if ($term->tid == 61440){ // Working with term 61440 | |
| $term_name = $new_value; | |
| $new_term = taxonomy_term_load($term->tid); | |
| $new_term->name = $term_name; | |
| print_r($new_term); | |
| taxonomy_term_save($new_term); | |
| } | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment