Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm using migrate to import a bunch of nodes and I want to set the path alias during the migration. I am able to import the path alias just fine like so:

$this->addFieldMapping('path', 'url_alias');

When I look at the imported nodes I see the correct path in the path field, but the Generate automatic URL alias checkbox is still checked which means the setting is getting ignored.

How do I disable that setting on the node during migration?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

You basically need to make sure the $node object is passed in with pathauto set to false when it is saved.

In your migration class:

function prepare(&$row) {
  $row->path['pathauto'] = 0;
}
share|improve this answer
    
I tried that, but the Generate automatic URL alias is still checked. –  Kenny Wyland Nov 22 '12 at 17:39
    
But I tried your suggestion in the prepare() method instead of prepareRow() and it worked! If you edit your post then I'll accept it as the answer. Thanks! –  Kenny Wyland Nov 22 '12 at 17:44
    
Edited--got the wrong method the first time around :) –  jhedstrom Nov 24 '12 at 7:22
add comment
$this->addFieldMapping('pathauto')->defaultValue(0);

Works for me. Pathauto: Perform aliasing (set to 0 to prevent alias generation during migration See 'drush ma' + name of your class for full description

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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