           @returnResult false, msg, callback
       .fail (msg) =>
         @returnResult false, msg, callback
+
+  publishOnly: (publish = true) ->
+    @publishProducts = true
+    @productService.getAllExistingProducts(@rest, not publish).then (existingProducts) =>
+      posts = []
+      for product in existingProducts
+        posts.push @publishProduct(product, publish, true)
+        @processInBatches posts, callback
+    .fail (msg) =>
+      @returnResult false, msg, callback
 
   initMatcher: (existingProducts) ->
     # console.log "initMatcher: ", _.size existingProducts


    deferred.promise

  publishProduct: (product, publish = true) ->
    deferred = Q.defer()
    unless @publishProducts
      deferred.resolve "Do not publish."
      return deferred.promise
    action = if publish then 'publish' else 'unpublish'
    data =
      id: product.id
      version: product.version

      ]
    @rest.POST "/products/#{product.id}", JSON.stringify(data), (error, response, body) ->
      if error
        deferred.reject "Error on #{action}ing product: " + error
      else
        if response.statusCode is 200
          deferred.resolve "Product #{action}ed."
        else if response.statusCode is 400
          if ignore400
            deferred.resolve "Product is already #{action}ed."
          else
            parsed = JSON.parse body
            humanReadable = JSON.stringify parsed, null, '  '
            deferred.reject "Problem on #{action}ing product:\n" + humanReadable
        else
          deferred.reject 'Problem on #{action}ing product: ' + body

    deferred.promise

