Created
July 31, 2017 17:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use like so:
./update-aliases.sh 'external/[node:title]' node external_content dev