Created
September 28, 2013 14:36
-
-
Save tarnus/6742691 to your computer and use it in GitHub Desktop.
Entity field query example
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
$query = new EntityFieldQuery(); | |
$query->entityCondition('entity_type', 'node') | |
->entityCondition('bundle', 'event') | |
->propertyCondition('status', 1); | |
$noderesult = $query->execute(); | |
if (isset($noderesult['node'])) { | |
$kb_items_nids = array_keys($noderesult['node']); | |
$kb_items = entity_load('node', $kb_items_nids); | |
// dsm($kb_items); | |
} | |
foreach ($kb_items as $item) { | |
$entity=$item; | |
$node_wrapper = entity_metadata_wrapper('node', $entity); | |
//update date field | |
$node_wrapper->field_date->set(strtotime($v['date'])); | |
$node_wrapper->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment