Jump to content

Drupal 7 entity_metadata_wrapper not updating


Raxter

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

      }
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.