Skip to content

Instantly share code, notes, and snippets.

@aaronlifton3
Created June 5, 2010 20:50
Show Gist options
  • Save aaronlifton3/426985 to your computer and use it in GitHub Desktop.
Save aaronlifton3/426985 to your computer and use it in GitHub Desktop.
importing magento export CSV files into spree
require 'fastercsv'
n = 0
FasterCSV.foreach("export_all_products.csv") do |row|
if n != 0
puts "Adding new product: #{row[7]}"
product = Product.new
product.name = row[7]
product.description = row[27]
product.sku = row[5].to_s
product.price = row[22].to_d
product.save!
end
n += 1
end
puts ""
puts "Import Completed - Added: #{n} Products"
@aaronlifton3
Copy link
Author

Just run the following command (so the script has access to the database):
script/runner import.rb
and you're done.

@andyt
Copy link

andyt commented Nov 26, 2014

If only my use case was that simple :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment