Sha256: fc37b9794d8da6f1eac55c5dee0fbd5b01d46da4717bcebf4bd058f3e03fe2fa

Contents?: true

Size: 847 Bytes

Versions: 23

Compression:

Stored size: 847 Bytes

Contents

Spree::Sample.load_sample('variants')

country =  Spree::Country.find_by(iso: 'US')
location = Spree::StockLocation.find_or_create_by!(name: 'default')
location.update_attributes!(
  address1: 'Example Street',
  city: 'City',
  zipcode: '12345',
  country: country,
  state: country.states.first,
  active: true
)

product_1 = Spree::Product.find_by!(name: 'Denim Shirt')
product_2 = Spree::Product.find_by!(name: 'Checked Shirt')

product_1.master.stock_items.find_by!(stock_location: location).update!(count_on_hand: 1)
product_2.master.stock_items.find_by!(stock_location: location).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

23 entries across 23 versions & 1 rubygems

Version Path
spree_sample-4.1.15 db/samples/stock.rb
spree_sample-4.1.14 db/samples/stock.rb
spree_sample-4.1.13.1 db/samples/stock.rb
spree_sample-4.1.13 db/samples/stock.rb
spree_sample-4.2.0.rc2 db/samples/stock.rb
spree_sample-4.1.12 db/samples/stock.rb
spree_sample-4.2.0.rc1 db/samples/stock.rb
spree_sample-4.1.11 db/samples/stock.rb
spree_sample-4.1.10 db/samples/stock.rb
spree_sample-4.2.0.beta db/samples/stock.rb
spree_sample-4.1.9 db/samples/stock.rb
spree_sample-4.1.8 db/samples/stock.rb
spree_sample-4.1.7 db/samples/stock.rb
spree_sample-4.1.6 db/samples/stock.rb
spree_sample-4.1.5 db/samples/stock.rb
spree_sample-4.1.4 db/samples/stock.rb
spree_sample-4.1.3 db/samples/stock.rb
spree_sample-4.1.2 db/samples/stock.rb
spree_sample-4.1.1 db/samples/stock.rb
spree_sample-4.1.0 db/samples/stock.rb