From 8819034eb9b77b9bfea86064cf3f77a37c6c9426 Mon Sep 17 00:00:00 2001 From: philippspo Date: Wed, 4 May 2016 11:00:46 +0200 Subject: [PATCH] fix(customer-groups): wait for customer groups to be loaded before starting to import --- src/customer-import.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/customer-import.js b/src/customer-import.js index 4dbbbcb..f5452cd 100644 --- a/src/customer-import.js +++ b/src/customer-import.js @@ -33,9 +33,12 @@ export default class CustomerImport { processStream (customers, next) { // process batch - this.loadCustomerGroups() - return Promise.map(customers, (customer) => { - return this.importCustomer(customer) + return this.loadCustomerGroups() + .then(() => { + // customer groups are loaded now + return Promise.map(customers, (customer) => { + return this.importCustomer(customer) + }) }) .then(() => { // call next for next batch