Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi, I can not understand how to use migrate_extras and for example how to use geofield migrate extra support.
I have create a Migration class that work. In my "source" I have 2 "fields" called latitudine and longitudine. I have follow the instruction that I have found in geofiled.inc:
$geo_arguments = array(
'lat' => array('source_field' => 'latitudine'),
'lon' => array('source_field' => 'longitudine'),
);
// The geometry type should be passed in as the primary value.
$this->addFieldMapping('field_coordinate', 'Point')
->arguments($geo_arguments);
// Since the excerpt is mapped via an argument, add a null mapping so it's
// not flagged as unmapped.
$this->addFieldMapping(NULL, 'latitudine');
$this->addFieldMapping(NULL, 'longitudine');
But my "test node" is created (via migrate) without "geofileld" field (field_coordinate). But if I comment the lines above and insert this function:
public function prepare($node, stdClass $current_row) {
$node->field_coordinate = array(LANGUAGE_NONE => array(0 => array('geom' => 'POINT ('.$current_row->longitudine." ".$current_row->latitudine.')',
'geo_type' => 'point',
'lat' => $current_row->latitudine,
'lon' => $current_row->longitudine,
'left' => $current_row->longitudine,
'top' => $current_row->latitudine,
'right' =>$current_row->longitudine,
'bottom' => $current_row->latitudine,
)));
}
"geofield field" is "created".
Where is my error ?
M.
Comments
Comment #1
Jan van Diepen CreditAttribution: Jan van Diepen commentedI initially came up with the same code fragment.
I got the following message.
Googling the message did not bring me anything.
I went through the issue queue some more and found #1852202: Unable to migrate geofield data and #1997316: geofield 7.x-2.0-dev migration.
Based on these issues I made the following code changes:
This works for me.
Comment #2
DrCord CreditAttribution: DrCord commented