Closed (fixed)
Project:
Migrate
Version:
7.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Nov 2012 at 22:49 UTC
Updated:
29 Dec 2012 at 02:40 UTC
I'm having a heck of a time trying to set the "updated" field of an entity. I thought it would just be a matter of a field mapping and converting to a Unix timestamp:
In my migration class:
$this->addFieldMapping('updated', 'DATEMOD');
In my prepareRow():
$current_row->DATEMOD = strtotime($current_row->DATEMOD);
If I dsm the entity in the prepare() function, it's showing the timestamp in the "updated" field but a timestamp of the current date/date is what gets saved to the database. Am I missing something?
Thanks,
Mickey
Comments
Comment #1
mikeryanIt depends on how that particular entity handles its 'updated' field. I would bet that (like nodes with the 'changed' field) it's got the timestamp hard-coded:
If that's the case, you'll need to write it out yourself after the entity is saved:
Comment #2
mikeryanNo further info provided.
Comment #3
micnap commentedSorry, haven't gotten back to this. It's on the agenda for the next week.
Thanks,
Mickey
Comment #4
Canadaka commentedI cannot figure out how to get the updated time of the nodes being migrated to not be set my time() but instead use the value from my source.
tried this but doesn't work, still gets current time.
Comment #5
micnap commentedFinally got back to this...
The suggested solution didn't work for me either but it put me on the right track. My entity was overriding the date on entity_save so I just did a db_update query in the complete function.
Thank you!
Mickey