Skip to content

Instantly share code, notes, and snippets.

@dsnopek
Created May 7, 2014 12:07
Show Gist options
  • Save dsnopek/ed50a736e36b82d2b497 to your computer and use it in GitHub Desktop.
Save dsnopek/ed50a736e36b82d2b497 to your computer and use it in GitHub Desktop.
<?php
$type = 'product_kit';
$field = 'field_availability';
$value = 'in stock';
$result = db_query("SELECT nid, vid FROM {node} WHERE type = :type", array(':type' => $type))->fetchAllAssoc('nid');
foreach ($result as $nid => $values) {
$fields = array(
'entity_type' => 'node',
'bundle' => $type,
'deleted' => 0,
'entity_id' => $values->nid,
'revision_id' => $values->vid,
'language' => LANGUAGE_NONE,
'delta' => 0,
"{$field}_value" => $value,
);
db_insert("field_data_{$field}")
->fields($fields)
->execute();
db_insert("field_revision_{$field}")
->fields($fields)
->execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment