 
     deferred.promise
 
-  publishProduct: (product, publish = true) ->
+  publishProduct: (product, publish = true, ignore400 = false) ->
     deferred = Q.defer()
+    action = if publish then 'publish' else 'unpublish'
     unless @publishProducts
-      deferred.resolve "Do not publish."
+      deferred.resolve "Do not #{action}."
       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 publishing product: ' + error
      else
        if response.statusCode is 200
          deferred.resolve 'Product published.'
        else if response.statusCode is 400
          parsed = JSON.parse body
          humanReadable = JSON.stringify parsed, null, '  '
          deferred.reject "Problem on publishing product:\n" + humanReadable
        else
          deferred.reject 'Problem on publishing product: ' + body

    deferred.promise


          @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
