module Spree
  class ProductExport < ActiveRecord::Base
    has_attached_file :attachment
    validates_attachment :attachment, content_type: { content_type: "text/csv" }
    after_commit :run_export, on: :create

    def finished?
      total_rows == processed_rows
    end

    def finish_percent
      if total_rows > 0
        processed_rows / total_rows * 100.0
      else
        100
      end
    end

    private

    def run_export
      SpreeProductsExport::ExportGenerator.generate(self)
    end

  end
end


module Spree
  class ProductExport < ActiveRecord::Base
    has_attached_file :attachment
    validates_attachment :attachment, content_type: { content_type: "text/csv" }
    after_commit :run_export

    def finished?
      total_rows == processed_rows
    end

    def finish_percent
      if total_rows > 0
        processed_rows / total_rows * 100.0
      else
        100
      end
    end

    private

    def run_export
      SpreeProductsExport::ExportGenerator.generate(self)
    end

  end
end


--- 
+++ 
@@ -2,7 +2,7 @@
   class ProductExport < ActiveRecord::Base
     has_attached_file :attachment
     validates_attachment :attachment, content_type: { content_type: "text/csv" }
-    after_commit :run_export
+    after_commit :run_export, on: :create
 
     def finished?
       total_rows == processed_rows
Fix commit issue for run process
