               @logger.warn "Found more than 1 #{refKey} for #{ref.id}"
             @_cache[refKey][ref.id] = result.body.results[0]
             if refKey is 'productType'
-              @logger.info "putting product type in cache in id: #{result.body.results[0].id}"
               @_cache[refKey][result.body.results[0].id] = result.body.results[0]
             resolve(result.body.results[0].id)
 

  #   productTypeId: [{updateAction},{updateAction},...]
  # }
  _filterUniqueUpdateActions: (updateActions) =>
    @logger.info 'filtering unique update actions ->'
    console.log JSON.stringify(updateActions, null, 2)
    uniqueUpdateActions = {}
    _.each _.keys(updateActions), (productTypeId) =>
      actions = updateActions[productTypeId]
      uniqueActions = @commonUtils.uniqueObjectFilter actions
      uniqueUpdateActions[productTypeId] = uniqueActions
    console.log JSON.stringify(uniqueUpdateActions, null, 2)
    uniqueUpdateActions

  _objectFilter: (objCollection) =>
    uniques = []
    _.each objCollection, (obj) =>
      if not @_isObjectPresentInArray(uniques, obj) then uniques.push(obj) else console.log 'duplicate found'
    uniques


  _isObjectPresentInArray: (array, object) ->
    present = false
    _.each array, (element) ->
      if _.isEqual(object, element)
        present = true
    present

  _ensureProductTypesInMemory: (products) =>
    Promise.map products, (product) =>

  _processBatches: (products) ->
    batchedList = _.batchList(products, 30) # max parallel elem to process
    Promise.map batchedList, (productsToProcess) =>
      debug 'Ensuring existence of product type in memory.'
      @_ensureProductTypesInMemory(productsToProcess)
      .then =>
        if @ensureEnums
          debug 'Ensuring existence of enum keys in product type.'
          enumUpdateActions = @_validateEnums(productsToProcess)
          uniqueEnumUpdateActions = @_filterUniqueUpdateActions(enumUpdateActions)
          @_updateProductType(uniqueEnumUpdateActions)
      .then =>
        # extract all skus from master variant and variants of all jsons in the batch
        skus = @_extractUniqueSkus(productsToProcess)
        predicate = @_createProductFetchBySkuQueryPredicate(skus)
