spree/spree — pull request #1189 by citrus (2012-02-24 10:49:59+00:00)
Title: New Feature - create a product with variants from a hash of option types & values

This pull request adds the ability to create variants for products from a hash of option_types and option_values. Basically you can do something like this:

```bash
rails console
```

```ruby
size = Spree::OptionType.create(:name => "size", :presentation => "Size")
%w(Small Medium Large).each do |name|
size.option_values.create(:name => name.downcase, :presentation => name)
end

color = Spree::OptionType.create(:name => "color", :presentation => "Color")
%w(Red White).each do |name|
color.option_values.create(:name => name.downcase, :presentation => name)
end

options = {}
Spree::OptionType.all.each do |ot|
options[ot.id.to_s] = ot.option_value_ids
end

puts options
#=> {"1"=>[1, 2, 3], "2"=>[4, 5]}

product = Spree::Product.create(:name => "Zomg!", :price => 5, :option_values_hash => options)

puts product.variants.count
#=> 6
```

### Why?!

...so we can create new products & variants from prototypes! Once you select a prototype from the new product page you'll get a group of checkboxes for each option type and it's option values. Select whichever type/value combo you'd like then click create. Now visit the product variants page and see your newly created variants.

If you'd like to see it in action, just check out the video:

http://vimeo.com/37367111

Specs are included and all are passing :beer: :beer: