diff --git a/migrate.inc b/migrate.inc index 9b72c81..61518b3 100644 --- a/migrate.inc +++ b/migrate.inc @@ -15,7 +15,13 @@ class MigrateRedirectEntityHandler extends MigrateDestinationHandler { } public function complete($entity, stdClass $row) { - if (($destination = entity_uri('node', $entity)) && !empty($entity->migrate_redirects)) { + + //Looking up the destination entity type for the current Migration + $migration = Migration::currentMigration(); + $destination = $migration->getDestination(); + $entity_type = $destination->getEntityType(); + + if (($redirect_destination = entity_uri($entity_type, $entity)) && !empty($entity->migrate_redirects)) { if (!is_array($entity->migrate_redirects)) { $entity->migrate_redirects = array($entity->migrate_redirects); } @@ -28,7 +34,7 @@ class MigrateRedirectEntityHandler extends MigrateDestinationHandler { ); $redirect = new stdClass(); redirect_object_prepare($redirect, $redirect_defaults); - $redirect->redirect = $destination['path']; + $redirect->redirect = $redirect_destination['path']; $parsed = redirect_parse_url($path); $redirect->source = $parsed['path']; $redirect->source_options['query'] = $parsed['query'];