Sha256: 7731132a2e4e815d2fb496ebb9533812d3cb8af57e8074d715a43fbb68c39884
Contents?: true
Size: 906 Bytes
Versions: 21
Compression:
Stored size: 906 Bytes
Contents
Spree::Sample.load_sample('variants') country = Spree::Country.find_by(iso: 'US') location = Spree::StockLocation.find_or_create_by!(name: 'default', propagate_all_variants: false) location.update( address1: 'Example Street', city: 'City', zipcode: '12345', country: country, state: country.states.first, active: true ) Spree::StockLocations::StockItems::Create.call(stock_location: location) product_1 = Spree::Product.find_by!(name: 'Denim Shirt') product_2 = Spree::Product.find_by!(name: 'Checked Shirt') location.stock_item_or_create(product_1.master).update(count_on_hand: 1) location.stock_item_or_create(product_2.master).update(count_on_hand: 1) Spree::Variant.all.each do |variant| next if variant.is_master? && variant.product.has_variants? variant.stock_items.each do |stock_item| Spree::StockMovement.create(quantity: rand(20..50), stock_item: stock_item) end end
Version data entries
21 entries across 21 versions & 1 rubygems