I have performed the following query:

$query = db_select('sage.USER', 'USER')
  ->fields('USER', array('USER_ID', 'OFFICE_ID', 'USER_PASSWORD'))
  ->range(0, 1);
$result = $query->execute();
$url = '/sage/office-' . $result->office_id;
$arguments = MigrateLinkFieldHandler::arguments(array('source_field' => 'office_id'));
$this->addFieldMapping('field_office_id', $url);

However, the above is not working. I would like to manipulate the 'office_id' field to be used as the 'title' and the variable $url to be used as the URL that was linked. I have followed what's on this post

Could someone please point out my mistakes?

EDIT: Updated question to reflect jdu's answer.

  • could anyone provide any insight into the correctness of my syntax? – chlong Apr 12 '12 at 17:54

The link.migrate.inc file is not included in the Migrate Extras module, it's part of the Link module.

The file doesn't exist in the stable version of Link, but it does exist in the dev release. I think you're going to have to install the dev version of Link if you want this to work.

If you install the dev version and still get the error it's most likely because the file is not being automatically included. If that's the case try adding this to the top of your code:

module_load_include('inc', 'link', 'link.migrate');


As I mentioned in your other question there's a slight error in your code, you should change this line:

$result = $query->execute();


$result = $query->execute()->fetchObject();

That will return an object representing the first result that was returned by the query.

  • Hi Clive thank you very much. I've found the file and put it in link.migrate.inc and it no longer complains about the file. I am now just getting partial, incomplete migrations of the link 'title' and 'url' fields. – chlong Apr 13 '12 at 17:02
  • I just answered your newer question, that might help a bit :) – Clive Apr 13 '12 at 17:03
  • Yes it does a lot! I don't know if it's proper, but should I give you the bounty for it? Even though you answered the one without it lol... – chlong Apr 13 '12 at 17:09
  • I really don't know to be honest, seems like these questions should be merged but I don't think that can be done when there's a bounty open on one of them. It might be worth asking a question on how best to proceed on the meta site, I'm sure one of the mods will weigh in :) – Clive Apr 13 '12 at 17:22
  • 1
    Questions are merged if the questions are exact duplicates; in this case, the other question is more generic than this one, and they cannot be merged. Also, the answer for this question ("The link.migrate.inc file is not included in the Migrate Extras module") is not the answer for the other question. – apaderno Apr 13 '12 at 18:18

This is how I imported nodes:

  • Download link.migrate.inc from link 7.x dev version and add this file to your module
  • Add file entry in your .info module (files[] = link.migrate.inc)
  • Apply this patch link-migrate_subfields.patch
  • Then you can use the following code:

    $this->addFieldMapping('field_portrait_affiliation_link', 'field_portrait_affiliation_link');
    $this->addFieldMapping('field_portrait_affiliation_link:title', 'field_portrait_affiliation_link:title');
    $this->addFieldMapping('field_portrait_affiliation_link:attributes', 'field_portrait_affiliation_link:attributes');
    $this->addFieldMapping('field_portrait_affiliation_link:language', 'language');

Fill a new variable with the results of executing your query:

$result = $query->execute();

$url = 'office-' . $result->office_id;
  • jdu, still crashing, it says Class MigrateLinkFieldHandler could not be found. I thought this was included in Migrate Extras? – chlong Apr 4 '12 at 19:01
  • drupal.org/project/migrate_extras yep, says it's built in. is there a file called "link.migrate.inc" ? perhaps installation of the module failed somehow. I'd upload the module to the directory again, check permissions and dependencies. there's always the web servers "error_log" file too, just in case something is being generated in there that could be more helpful. – jdu Apr 4 '12 at 19:39
  • hmm thanks it really isn't in there...i'll keep digging.. – chlong Apr 4 '12 at 19:54

Have you checked: /admin/content/migrate/configure

There check the Field handlers for the link field:

[x] link MigrateLinkFieldHandler link_field

Install the dev version of the Link module. Then this should work:

$arguments = array('title' => array('source_field' => 'office_id'));
$this->addFieldMapping('field_office_id', 'field_office_id_path')->arguments($arguments);

function prepareRow($row) {
    $row->field_office_id_path = '/sage/office-' . $row->office_id;
  • $arguments = array('title' => array('source_field' => 'office_id')); should be $arguments = array(array('source_field' => 'office_id')); – fotuzlab May 3 '16 at 5:56

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.