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?

3 Answers 3


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;
  • I tried that, but the Generate automatic URL alias is still checked. Commented Nov 22, 2012 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! Commented Nov 22, 2012 at 17:44
  • Edited--got the wrong method the first time around :)
    – jhedstrom
    Commented Nov 24, 2012 at 7:22

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


If you'll sometimes but not always have an incoming path alias, then here's how you can trigger pathauto only when you haven't set an alias.

First, in the constructor, map both path and pathauto:

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

Then, in ::prepareRow(), set the pathauto property depending on whether there's an incoming path value:

public function prepareRow($row) {

  if (!empty($row->path)) {
    $row->pathauto = 0;
  else {
    $row->pathauto = 1;


The result is that if you've explicitly passed in a path that will be used for the alias, while if you haven't Pathauto will kick in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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