Jump to content


Photo

Drupal 7 entity_metadata_wrapper not updating


  • Please log in to reply
No replies to this topic

#1 Raxter

Raxter
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 17 February 2017 - 02:11 PM

I am in need of serious help. I have been working on this issue and researching for weeks. I am using entity metadata wrapper to update a time value. I am not encountering any errors. It is just not updating. I am using set() to update the value. Any ideas or input??

 

This is when the original value is set in the node:

$node->field_event_dates[$node->language][0]['value2'] = strtotime($event->endTime);

When I try to update the endtime, nothing updates:

$feed_data = $json_data->dissertations;

     foreach ($feed_data as $event) {
      // make sure it doesn't already exist
	  
      $event_nids = FALSE;
      $query = new EntityFieldQuery(); 
      $query->entityCondition('entity_type', 'node') 
        ->entityCondition('bundle', 'event')
	->propertyCondition('field_form_id', $event->{'form_id'}, '=')
        ->fieldCondition('field_event_dates', 'value', strtotime($event->startTime) , '=')
        ->range(0, 1) //($start, $length)
        ->addMetaData('account', user_load(1)); // Run the query as user 1.
		
      $result = $query->execute();
	  
      if (isset($result['node'])) { // existing so update 
        $counter_existing++;     
		 //added to update event when a change
		$node = node_load($nid);
		$node_wrapper = entity_metadata_wrapper('node', $node);		
		$node_wrapper->field_event_dates->set(array('value2'=> strtotime($event->endTime)));	
		$node_wrapper->save();

      }





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users