I have created a computed field that I need for all my nodes. However I have 100s of nodes and for the computed field to show I have to click edit and then save for each one. This is going to take a LONG TIME!
Is there a way to run a rule or something so I can re-save all the nodes together.

Comments

Dave Kopecek’s picture

You can probably use views and views_bulk_operations, or you can do something like this in a module:

/**
* Loop through computed fields  and update totals
**/
function mymodule_update_totals() {

$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'mycontenttype')
->propertyCondition('status', 1);
$result = $query->execute();
$nids = array_keys($result['node']);

// Loading and saving the node will trigger calculated field creation.
foreach($nids as $nid) {
  $node = node_load($nid);
  $node->revisions = 1;
  $node->log = "Computed Fields updated";
  node_save($node);
}
return true;
}
jeffschuler’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)