Jump to content
Sign in to follow this  
Raxter

Drupal 7 entity_metadata_wrapper not updating

Recommended Posts

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();

      }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  



×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.