I have multiple CSV files in different folders. The folder names are the node ids. And each folder contains its own CSV file. Now I want to loop these directories and import from the CSV files in one migration class but it only migrate from the last CSV file.
Here is my code
class MigrateNodes extends Migration {
public function __construct($arguments) {
parent::__construct();
$columns[0] = array('Number', 'Number');
$columns[1] = array('Title', 'Title');
$columns[2] = array('Description', 'Description');
//The Description of the import. This desription is shown on the Migrate GUI
$this->description = t('Import lots from excell file ');
$nids = db_select('node', 'n')
->fields('n', array('nid'))
->condition('n.type', 'type')
->execute()
->fetchCol();
foreach ($nids as $nid) {
$path = $nid . "/nodes.csv";
//The Source of the import
$this->source = new MigrateSourceCSV($path', $columns, array('header_rows' => 1));
if ($this->source) {
$this->destination = new MigrateDestinationNode('lot');
$this->map = new MigrateSQLMap(
$this->machineName, array(
"Number" => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'alias' => 'import'
)
), MigrateDestinationNode::getKeySchema()
);
//Field ampping
$this->addFieldMapping('title', 'Title');
$this->addFieldMapping('field_lot_description', 'Description');
//}
}
}
}
}
The Number field is unique. Any one knows what I am doing wrong?