diff --git a/sites/all/modules/contrib/migrate/plugins/sources/spreadsheet.inc b/sites/all/modules/contrib/migrate/plugins/sources/spreadsheet.inc index 5925b36..cd6fe30 100644 --- a/sites/all/modules/contrib/migrate/plugins/sources/spreadsheet.inc +++ b/sites/all/modules/contrib/migrate/plugins/sources/spreadsheet.inc @@ -67,6 +67,11 @@ class MigrateSourceSpreadsheet extends MigrateSource { protected $rowNumber; /** + * The columns to be read from Excel + */ + protected $columns; + + /** * Simple initialization. * * @param string $path @@ -76,10 +81,11 @@ class MigrateSourceSpreadsheet extends MigrateSource { * @param array $options * Options applied to this source. */ - public function __construct($path, $sheet_name, array $options = array()) { + public function __construct($path, $sheet_name, $columns = array(), array $options = array()) { parent::__construct($options); $this->file = $path; $this->sheetName = $sheet_name; + $this->columns = $columns; // Load the workbook. if ($this->load()) { @@ -208,18 +214,10 @@ class MigrateSourceSpreadsheet extends MigrateSource { migrate_instrument_start('MigrateSourceSpreadsheet::next'); ++$this->rowNumber; - // 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_fields)) { + if (in_array($this->fields[$col], $this->columns) || empty($this->columns)) { $row_values[$this->fields[$col]] = trim($this->worksheet->getCellByColumnAndRow($col, $this->rowNumber)->getValue()); } }