diff --git a/plugins/sources/spreadsheet.inc b/plugins/sources/spreadsheet.inc index b7b6de7..5925b36 100644 --- a/plugins/sources/spreadsheet.inc +++ b/plugins/sources/spreadsheet.inc @@ -208,12 +208,18 @@ class MigrateSourceSpreadsheet extends MigrateSource { migrate_instrument_start('MigrateSourceSpreadsheet::next'); ++$this->rowNumber; - $source_keys = array_keys($this->activeMap->getSourceKey()); + // Only take into account the fields actually used in source. + $mappings = Migration::currentMigration()->getFieldMappings(); + $source_fields = array(); + foreach ($mappings as $mapping) { + $source_fields[] = $mapping->getSourceField(); + } + if ($this->rowNumber <= $this->rows) { $row_values = array(); for ($col = 0; $col < $this->cols; ++$col) { - if (in_array($this->fields[$col], $source_keys)) { + if (in_array($this->fields[$col], $source_fields)) { $row_values[$this->fields[$col]] = trim($this->worksheet->getCellByColumnAndRow($col, $this->rowNumber)->getValue()); } } @@ -228,5 +234,4 @@ class MigrateSourceSpreadsheet extends MigrateSource { return NULL; } } - }