diff --git a/app/models/product_import/product_importer.rb b/app/models/product_import/product_importer.rb index e7a7f8792f..5d8a3176d1 100644 --- a/app/models/product_import/product_importer.rb +++ b/app/models/product_import/product_importer.rb @@ -253,13 +253,7 @@ module ProductImport end def build_entries - rows.each_with_index do |row, i| - row_data = Hash[[headers, row].transpose] - entry = SpreadsheetEntry.new(row_data) - entry.line_number = i + 2 - @entries.push entry - end - @entries + @entries = build_entries_from_rows(rows) end def save_all_valid @@ -272,5 +266,14 @@ module ProductImport return unless @file.path == Rails.root.join('tmp', 'product_import').to_s File.delete(@file) end + + def build_entries_from_rows(rows) + rows.each_with_index.inject([]) do |entries, (row, i)| + row_data = Hash[[headers, row].transpose] + entry = SpreadsheetEntry.new(row_data) + entry.line_number = i + 2 + entries.push entry + end + end end end