Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8045073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:25:48+00:00 2026-06-05T05:25:48+00:00

I sync data from external source to my Drupal installation. I have problem when

  • 0

I sync data from external source to my Drupal installation. I have problem when i’m adding taxonomy term relation to my newly created node.

I’m syncing cars and if manufacturer name ($name in code) is not in vocabulary, it will get added to it. If it already exists, tid attached to node.

This works perfectly with terms like Ferrari or Volkswagen. But then there is Mercedes-Bentz. For some reason EntityFieldQuery doesn’t seem to find it from vocabulary, because this code, when run in loop, creates Mercedes-Bentz terms over and over again.

I guess the problem is that dash between words. I’d like to see SQL clause behind EntityFieldQuery, but i don’t have entire drupal setup up when i’m running this, so modules like Devel are not loaded. And I don’t have a clue how to inspect SQL otherwise.

I’m more than grateful of suggestions how to debug or how to solve this. Every link is appreciated.

Here is my code:

$query = new EntityFieldQuery();
$result = $query
    ->entityCondition('entity_type', 'taxonomy_term')
    ->propertyCondition('name', $name) // $name = manufacturer, like "Ferrari"
    ->propertyCondition('vid', 2)
    ->execute();

if(!empty($result))
{
    $tmp = array_pop($result['taxonomy_term']);
    $node->field_brand[LANGUAGE_NONE][0]['tid'] = $tmp->tid;
}
else
{
    $term = new stdClass();
    $term->vid = 2;
    $term->name = $name
    taxonomy_term_save($term);
    $node->field_brand[LANGUAGE_NONE][0]['tid'] = $term->tid;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:25:50+00:00Added an answer on June 5, 2026 at 5:25 am

    There is a way to do the same with taxonomy_get_term_by_name(), but i guess it is not preferred way and the solution explained in question should be right for this.

    I think we are seeing Drupal bug here. But for others trying to do that, here is the solution:

    $test = taxonomy_get_term_by_name($name);
    // It should be full of unique names, so no need to go through all of them
    if(!empty($test))
    {
        $tmp = array_pop($test);
        $node->field_brand[LANGUAGE_NONE][0]['tid'] = $tmp->tid;
    }
    else
    {
        $term = new stdClass();
        $term->vid = 2;
        $term->name = $name;
        taxonomy_term_save($term);
        $node->field_brand[LANGUAGE_NONE][0]['tid'] = $term->tid;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're designing data import from an external source like MAS200 into our production SQL
When I sync data from Active directory, and any object attributes have reserve character
Which software can you recommend to sync data from a FoxPro source to a
I want sync data from iphone to the webs server. My question is how
I am using the Single Access Token from authlogic to sync data from a
What do you use for data synchronization? I have been working with Microsoft Sync
I'm using Microsoft Sync framework 1.0 (without ADO.NET services) I have created 2 custom
im developing an Android application for twitter that will sync data coming from the
I have a Silverlight app that uses actions to get data from the model
Hey guys, I have an application that I want to display some data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.