0

I have several Blank sources in a Feed and I'm mapping a value to these blank sources in my custom code.

I have a working example to set a value of a field of type 'TEXT FIELD':

function set_profile_value(FeedsSource $source, $entity, $target, array $values, array $mapping) {
    if (substr($source->id, 0, 7) == 'my_data') {
        if (!empty($mapping['profile'])) {
            $entity->{$target}[$entity->language][0]['value'] = $mapping['profile'];
        }
    }
}

My question is, how to do the same if the field is a term reference?

Thanks!

0

It was simpler than what I thought.

The code is exactly the same, but instead of 'value', we have to use 'tid':

function set_profile_value(FeedsSource $source, $entity, $target, array $values, array $mapping) {
    if (substr($source->id, 0, 7) == 'my_data') {
        if (!empty($mapping['profile'])) {
            $entity->{$target}[$entity->language][0]['tid'] = $mapping['profile'];
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.