diff --git a/app/assets/javascripts/admin/product_import/controllers/import_form_controller.js.coffee b/app/assets/javascripts/admin/product_import/controllers/import_form_controller.js.coffee index d1454307dc..174d0049d9 100644 --- a/app/assets/javascripts/admin/product_import/controllers/import_form_controller.js.coffee +++ b/app/assets/javascripts/admin/product_import/controllers/import_form_controller.js.coffee @@ -60,18 +60,20 @@ angular.module("admin.productImport").controller "ImportFormCtrl", ($scope, $htt $scope.processBatch = (step, batchIndex, batchCount) -> start = (batchIndex * $scope.batchSize) + 1 end = (batchIndex + 1) * $scope.batchSize - withNextBatch = batchIndex + 1 < batchCount + isLastBatch = batchCount == batchIndex + 1 promise = if step == 'import' $scope.processImport(start, end) else if step == 'save' $scope.processSave(start, end) + return if isLastBatch + processNextBatch = -> $scope.processBatch(step, batchIndex + 1, batchCount) # Process next batch whether or not processing of the current batch succeeds. - promise.then(processNextBatch, processNextBatch) if withNextBatch + promise.then(processNextBatch, processNextBatch) $scope.processImport = (start, end) -> $http(