Created
December 31, 2020 05:14
-
-
Save arpitr/e223ce73496d64ad38dd486f70d70a23 to your computer and use it in GitHub Desktop.
Attach media to all article nodes
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
// replace 119751 with media entity ID | |
drush php-eval '$nids = \Drupal::entityQuery("node")->condition("type","article")->execute();$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);$media = \Drupal\media\Entity\Media::load(119751);foreach($nodes as $node) {$node->field_hero_media->entity = $media;$node->save();}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment