           deferred.resolve message
     deferred.promise
 
-  _batch: (list, numberOfParallelRequest) =>
-    current = _.take list, numberOfParallelRequest
-    Q.all(current)
-    .then (result) =>
-      if _.size(current) < numberOfParallelRequest
-        @success = true
-      else
-        @_batch _.tail(list, numberOfParallelRequest), numberOfParallelRequest
-    .fail (error) =>
-      @logger.error "Error batch processing; #{error}"
-      @logger.error "Error stack: #{error.stack}" if error.stack
-      @success = false
-
-  _buildProductsData: (data, productType) =>
+  _batch: (list, numberOfParallelRequest) ->
+    deferred = Q.defer()
+    doBatch = (list, numberOfParallelRequest) ->
+      current = _.take list, numberOfParallelRequest
+      Q.all(current)
+      .then (result) ->
+        if _.size(current) < numberOfParallelRequest
+          # @success = true
+          deferred.resolve true
+        else
+          doBatch _.tail(list, numberOfParallelRequest), numberOfParallelRequest
+      .fail (error) ->
+        # @logger.error "Error batch processing; #{error}"
+        # @logger.error "Error stack: #{error.stack}" if error.stack
+        # @success = false
+        deferred.reject error
+     doBatch(list, numberOfParallelRequest)
+     deferred.promise
+
+  _buildProducts: (data, productType, fetchedCategories) =>
     products = []
     _.each data.Products?.Product, (p) =>
       names = @_getLocalizedValue(p.Descriptions[0], 'Title')

      slugs[key] = slug
    slugs

  _getProductType: (productTypesObj) ->
    productTypes = productTypesObj.results
    if _.size(productTypes) == 0
      throw new Error "No product type defined for SPHERE project '#{@_options.config.project_key}'. Please create one before running product import."


      @_processImages(item, product, variant)

    variant

  _processCategories: (product, data) ->
    catReferences = []
    _.each data.Categories?.Category, (c) =>
      categoryId = c.CategoryId[0]
      existingCategory = @_getCategoryByExternalId(categoryId, fetchedCategories)
      id = existingCategory.id
      reference =
        typeId: "category"
        id: id
      catReferences.push reference

    if _.size(catReferences) > 0
      product.categories = catReferences

  _processImages: (item, product, variant) ->
    _.each item, (value, key) =>
