         else
           @apiClient.getByExternalIds [category.parent.id]
           .then (result) ->
-            if results.count is 1
+            if result.body.count is 1
               category.parent.id = result.body.results[0].id
               resolve category
             else

    @currentCandidates = []

  addMapping: (category) ->
    @externalId2IdMap[category.externalId] = category.id

  initialize: (categories) ->

      cat = _.find @currentCandidates, (candidate) ->
        candidate.externalId is category.externalId
      if cat
        @logger.info "Found match for externalId '#{cat.externalId}' with id '#{cat.id}'."
        @addMapping cat
      else
        msg = "No match found for category with external id '#{category.externalId}'"
        @logger.info msg
