Migrate CSV source serial I am using migrate to import Commerce Products from a CSV file. The CSV file doesn't have its own serial so I am using csvrownum but that obviously won't work if there are already products -- I will be migrating constantly from the CSV files and so I need a real serial. So the big question is, how do I tell Migrate to generate its own serial? prepareRow feels too late because it seems I need to supply MigrateSQLMap a key field.

Here's a rough version of the constructor of the class:

public function __construct() {
  parent::__construct();
  $this-&gt;description = t('Test CSV');

  $columns = array(
    array('product_name', 'title'),
    array('url', 'url'),
    array('price', 'price'),
  );

  $this-&gt;source = new MigrateSourceCSV('/tmp/test.csv', $columns, array('header_rows' =&gt; 1));

  $this-&gt;destination = new MigrateDestinationCommerceProduct('commerce_product', 'product');

  $this-&gt;map = new MigrateSQLMap($this-&gt;machineName,
    array(
      'csvrownum' =&gt; array(
        'type' =&gt; 'int',
        'not null' =&gt; true,
      ),
    ),
    MigrateDestinationCommerceProduct::getKeySchema('commerce_product')
  );

  $this-&gt;addFieldMapping('product_id', 'csvrownum');
  $this-&gt;addFieldMapping('title', 'title');
  $this-&gt;addFieldMapping('field_url', 'url');
  $this-&gt;addFieldMapping('commerce_price', 'price');
}
Meanwhile I got this figured out. The second argument of MigrateSQLMap is a field => schema array and you can fill in those fields in function prepareKey($source_key, $row) as necessary, say

function prepareKey($source_key, $row) {
  $row-&gt;vendor_id = $this-&gt;vendorId;
  return parent::prepareKey($source_key, $row);
}


Note: prepareRow is too late, you want prepareKey.