Posted by alanburke on November 9, 2011 at 11:27am
3 followers
Jump to:
| Project: | Migrate |
| Version: | 7.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
On some of my migrations, the source table is missing values for some of the fields.
When migrating into Drupal, it still imports that missing value.
So some fields have a label, but no value.
If I even just edit and save the node (with no other changes), the blank value is removed [and the label no longer shows].
Is there any way to avoid these 'Phantom Values'?
Comments
#1
implement method YourMigration::prepareRow
public function prepareRow($row) {if (empty($row->default_zero_field))
unset($row->default_zero_field);
}
#2
Thanks Andrey!
I implemented a cleanup function in my base class
<?phppublic function __prepareRow($current_row) {
foreach($current_row as $field=>$value){
if (empty($value) && $value !="0"){
unset($current_row->$field);
}
}
}
?>
and I call that within prepare_Row for each migration.
#3
Automatically closed -- issue fixed for 2 weeks with no activity.