I have a site being migrated from Drupal 6 to 7. The old site had a home grown system for adding payments to signups for event nodes. We plan to use commerce module to selling the registrations for events going forward.

In the new site, we are planning to import the preexisting SKUs from the old site with feeds but I want to include the product references with the event migration we have written. This migration is already working and just needs to have the product references added to it.

My question is about how to prepare the source data to be mapped when it looks something like this:

nid | sku
1   | a
1   | b
1   | c
2   | a
2   | d

When it seems like it would be better if the data was like this:

nid | sku
1   | a,b,c
2   | a,d

I think if I had the like the second table, I could join the source table

// Join payment_options_skus table
$query->join('payment_options_skus', 'pos', 'pos.nid = n.nid');
$query->fields('pos', array('sku'));

and then map like so:

$this->addFieldMapping('field_registration', 'sku')

Is there a better way to do it using the existing data in the first example table? I would like to limit the number of manual massaging steps needed. Thanks.

2 Answers 2


I'm in a similar boat, but doing an import for a content type. If data is prepared with multi-value fields as in your second table, I can import the data using Feeds and the plugin 'Feeds Tamper'. So I'm also looking at repeatable and efficient ways to arrange data with multi-fields in CSV format. Saw a post about using Drupal 7 'Feeds Tamper PHP' to do create the multi-valued fields here, https://www.reddit.com/r/drupal/comments/2tumv9/drupal_7x_feeds_tamper_column_values_to_single/co2hesj. <-- Untested, just a reference. HTH.

  • Well, I need to move this project forward so this morning I set up a spreadsheet with the data and concatenated the skus together with a "|" character as a separator. I didn't want to use Feeds as I have already written a migration for the content type. I got it to work and will document my solution later today.
    – maddentim
    Jan 6, 2016 at 20:43

I was unable to find a way to import the product references as they were in the original data structure. Instead, using Libreoffice Calc, I wrote some concatenate functions to merge the rows so that I had one rows per event node. Also, I found that I needed the "product_id" of the product, not its SKU. For that, I imported the commerce_products table into my spreadsheet and then did a VLOOKUP to find the product_id for each SKU. I then exported the worksheet to a CSV file with this structure:

|1  |100,101,102
|2  |100,105

Then my mapping looked like so:

$this->addFieldMapping('field_registration', 'product_id')

And may source looked like:

// Join payment_options_skus table
$query->leftJoin('payment_options_skus', 'pos', 'pos.nid = n.nid');
$query->fields('pos', array('product_ids'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.