Sha256: 6d10ca877340791aa5435180aacffc12dcc79f751ee5ba95134575f8958f48ac

Contents?: true

Size: 835 Bytes

Versions: 19

Compression:

Stored size: 835 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(
  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

19 entries across 19 versions & 1 rubygems

Version Path
spree_sample-4.2.7 db/samples/stock.rb
spree_sample-4.3.3 db/samples/stock.rb
spree_sample-4.2.6 db/samples/stock.rb
spree_sample-4.3.2 db/samples/stock.rb
spree_sample-4.3.1 db/samples/stock.rb
spree_sample-4.3.0 db/samples/stock.rb
spree_sample-4.3.0.rc3 db/samples/stock.rb
spree_sample-4.3.0.rc2 db/samples/stock.rb
spree_sample-4.3.0.rc1 db/samples/stock.rb
spree_sample-4.2.5 db/samples/stock.rb
spree_sample-4.2.4 db/samples/stock.rb
spree_sample-4.2.3.1 db/samples/stock.rb
spree_sample-4.2.3 db/samples/stock.rb
spree_sample-4.2.2 db/samples/stock.rb
spree_sample-4.2.1 db/samples/stock.rb
spree_sample-4.2.0 db/samples/stock.rb
spree_sample-4.2.0.rc5 db/samples/stock.rb
spree_sample-4.2.0.rc4 db/samples/stock.rb
spree_sample-4.2.0.rc3 db/samples/stock.rb