       header: header
     new ExportMapping(options)
 
+  # return the correct product service in case query string is used or not
+  _getProductService: ->
+    productsService = @client.productProjections
+    if @queryOptions.queryString
+      productsService.byQueryString(@queryOptions.queryString, @queryOptions.isQueryEncoded)
+      if @queryOptions.queryType is 'search'
+        productsService.search()
+      else
+        productsService.fetch()
+    else
+      productsService.all().staged(staged).fetch()
+
   export: (templateContent, outputFile, staged = true) ->
     @_parse(templateContent)
     .then (header) =>

    # TODO:
    # - use process to export products in batches
    # - use streams to write data chunks
    @client.products.all().fetch()
    .then (result) =>
      products = result.body.results
      if _.size(products) is 0
        Promise.resolve 'No products found.'
      else
        console.log "Number of products: #{_.size products}."
        @_saveJSON(outputFile, products)
        .then -> Promise.resolve 'Export done.'


        header.toIndex()
        header.toLanguageIndex()
        exportMapping = @_initMapping(header)
        data = [
          @typesService.getAll @client
          @categoryService.getAll @client
          @channelService.getAll @client
          @customerGroupService.getAll @client
          @taxService.getAll @client
          @_getProductService()
        ]
        # TODO:
        # - use process to export products in batches
