Created
          June 5, 2010 20:50 
        
      - 
      
- 
        Save aaronlifton3/426985 to your computer and use it in GitHub Desktop. 
    importing magento export CSV files into spree
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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" | 
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
  
            
Just run the following command (so the script has access to the database):
script/runner import.rb
and you're done.