spree_sample 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1e4571f8b57e35772aaa32b6c7cfe2ae6ef1f4027db91345a8287f05edee92e
4
- data.tar.gz: 21996eb4d161ecdc46ea53fe8228b8dcad97c17a4056297d25515791311901fe
3
+ metadata.gz: e6f234b641d1c482be07af2a0880807eec787cbf282552bf104e06857c240651
4
+ data.tar.gz: 0e9ff36d0b307e5a746d8f67d498fe4ed03ea5689b8adfbf715144677f5d4390
5
5
  SHA512:
6
- metadata.gz: e3385415b170919d86aac0d1f748e542238a7dff56fa861bd459812bdf49e6b654820972b442730811f14da306d7062aaf8e502cc44d0eb94440826d18e2a6e6
7
- data.tar.gz: 05cafa166aa31260bd8a1630fdfe71fa4800c888fdb518f8c9be4ee5632fd721ddc7925695e203d833dd191a21d2af9a02965673404130d0b92a67a9db687164
6
+ metadata.gz: b413b1b1e7f7fe094025d82aefdc397a3f5af3abc3d926c097f7227d974fdc6b5f0e36a71edb8083fe925a1c00da9bc9298cec18a6150726738c20febefd5637
7
+ data.tar.gz: 446f172cb45eab05f65d70b8fd5d5c907bfed4825cd9a850cb7e1d80f4129516f69328744263c7e23d5a07e530f56f581317dbf74cc3289b7c3acf9f4bb821e7
@@ -20,7 +20,7 @@ end.uniq
20
20
  PRODUCTS.each do |(parent_name, taxon_name, product_name)|
21
21
  parent = Spree::Taxon.find_by!(name: parent_name)
22
22
  taxon = parent.children.find_by!(name: taxon_name)
23
- taxon.products.where(name: product_name.titleize).first_or_create! do |product|
23
+ Spree::Product.where(name: product_name.titleize).first_or_create! do |product|
24
24
  product.price = rand(10...100) + 0.99
25
25
  product.description = FFaker::Lorem.paragraph
26
26
  product.available_on = Time.zone.now
@@ -28,10 +28,13 @@ PRODUCTS.each do |(parent_name, taxon_name, product_name)|
28
28
  product.shipping_category = default_shipping_category
29
29
  product.tax_category = clothing_tax_category
30
30
  product.sku = [taxon_name.delete(' '), product_name.delete(' '), product.price].join('_')
31
- parent.products << product
31
+ product.taxons << parent unless product.taxons.include?(parent)
32
+ product.taxons << taxon unless product.taxons.include?(taxon)
32
33
  end
33
34
  end
34
35
 
35
- ['Bestsellers', 'New', 'Trending', 'Streetstyle', 'Summer Sale'].each do |taxon_name|
36
- Spree::Taxon.find_by!(name: taxon_name).products << Spree::Product.all.sample(30)
36
+ Spree::Taxon.where(name: ['Bestsellers', 'New', 'Trending', 'Streetstyle', 'Summer Sale']).each do |taxon|
37
+ next if taxon.products.any?
38
+
39
+ taxon.products << Spree::Product.all.sample(30)
37
40
  end
@@ -14,29 +14,28 @@ size_option_values = Spree::OptionType.find_by!(name: 'size').option_values
14
14
  VARIANTS.each do |(parent_name, taxon_name, product_name, color_name)|
15
15
  parent = Spree::Taxon.find_by!(name: parent_name)
16
16
  taxon = parent.children.find_by!(name: taxon_name)
17
- product = taxon.products.find_by!(name: product_name.titleize)
17
+ product = Spree::Product.find_by!(name: product_name.titleize)
18
18
  color = color_option_values.find_by!(name: color_name)
19
19
 
20
20
  size_option_values.each do |size|
21
21
  if parent_name == 'Women' and %w[Dresses Skirts].include?(taxon_name)
22
22
  length_option_values.each do |length|
23
23
  option_values = [color, length, size]
24
- product.variants.new do |variant|
24
+ product.variants.first_or_create! do |variant|
25
25
  variant.cost_price = product.price
26
26
  variant.option_values = option_values
27
27
  variant.sku = product.sku + '_' + option_values.map(&:name).join('_')
28
28
  variant.tax_category = clothing_tax_category
29
- variant.save!
30
29
  end
31
30
  end
32
31
  else
33
32
  option_values = [color, size]
34
- product.variants.new do |variant|
33
+ product.variants.first_or_create! do |variant|
35
34
  variant.cost_price = product.price
36
35
  variant.option_values = option_values
37
36
  variant.sku = product.sku + '_' + option_values.map(&:name).join('_')
38
37
  variant.tax_category = clothing_tax_category
39
- variant.save!
38
+
40
39
  end
41
40
  end
42
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_sample
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-02 00:00:00.000000000 Z
11
+ date: 2020-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.1.0
19
+ version: 4.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.1.0
26
+ version: 4.1.1
27
27
  description: Required dependency for Spree
28
28
  email: sean@spreecommerce.com
29
29
  executables: []