Skip to content

Instantly share code, notes, and snippets.

@markisatacomputer
Created July 31, 2017 17:58
Show Gist options
  • Save markisatacomputer/57d3edc13a6abe40229c753919d5e689 to your computer and use it in GitHub Desktop.
Save markisatacomputer/57d3edc13a6abe40229c753919d5e689 to your computer and use it in GitHub Desktop.
Drupal 7 - update url alias for entity bundle and bulk update all aliases for that bundle
#!/bin/bash
ALIAS_PATTERN="$1"
ENTITY_TYPE="$2"
ENTITY_BUNDLE="$3"
PANTHEON_ENV="$4"
drush @pantheon.exploratorium.$PANTHEON_ENV vset pathauto_${ENTITY_TYPE}_${ENTITY_BUNDLE}_pattern $ALIAS_PATTERN
drush @pantheon.exploratorium.$PANTHEON_ENV vset pathauto_update_action 2
SCR=" \$query = new EntityFieldQuery();
\$query->entityCondition('entity_type', '${ENTITY_TYPE}')->entityCondition('bundle', '${ENTITY_BUNDLE}');
\$result = \$query->execute();
if (isset(\$result['${ENTITY_TYPE}'])) {
\$ids = array_keys(\$result['${ENTITY_TYPE}']);
pathauto_taxonomy_${ENTITY_TYPE}_alias_multiple(\$ids, 'bulkupdate');
}"
echo $SCR | drush @pantheon.exploratorium.$PANTHEON_ENV php-script -
drush @pantheon.exploratorium.$PANTHEON_ENV vset pathauto_update_action 0
@markisatacomputer
Copy link
Author

Use like so:

./update-aliases.sh 'external/[node:title]' node external_content dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment