Skip to content

Instantly share code, notes, and snippets.

@rvalyi
Created March 11, 2010 16:42
Show Gist options
  • Save rvalyi/329321 to your computer and use it in GitHub Desktop.
Save rvalyi/329321 to your computer and use it in GitHub Desktop.
#provided the product_variant_multi module is installed
#notice that variant dimensions values are shared
require "rubygems"
require "ooor"
ooor = Ooor.new(:url => 'http://localhost:8069/xmlrpc', :username => 'admin', :password => 'admin', :database=>'mybase')
tmpl_id = ProductTemplate.create(:name => "My Product Template", :categ_id=> 1).id
dim_id = ProductVariantDimensionType.create(:product_tmpl_id => tmpl_id, :name => "Color").id
value_id1 = ProductVariantDimensionValue.create(:product_tmpl_id => tmpl_id, :dimension_id =>dim_id, :name => 'Red').id
dim_id2 = ProductVariantDimensionType.create(:product_tmpl_id => tmpl_id, :name => "Size").id
value_id2 = ProductVariantDimensionValue.create(:product_tmpl_id => tmpl_id, :dimension_id =>dim_id2, :name => 'Large').id
p = ProductProduct.create({:product_tmpl_id => tmpl_id, :dimension_value_ids => [value_id1, value_id2], :code => "MYSUPERCODE"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment