Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Make option types in sample products and their variants consistent

Piotr Matląg02c20481290a
diff --git a/sample/db/samples/products.rb b/sample/db/samples/products.rb
index cb52fe7cc6..7cec89eb13 100644
--- a/sample/db/samples/products.rb
+++ b/sample/db/samples/products.rb
@@ -11,6 +11,7 @@ clothing_tax_category = Spree::TaxCategory.find_by!(name: 'Clothing')
Spree::Config[:currency] = 'USD'
color = Spree::OptionType.find_by!(name: 'color')
+length = Spree::OptionType.find_by!(name: 'length')
size = Spree::OptionType.find_by!(name: 'size')
PRODUCTS = CSV.read(File.join(__dir__, 'variants.csv')).map do |(parent_name, taxon_name, product_name, _color_name)|
@@ -24,7 +25,11 @@ PRODUCTS.each do |(parent_name, taxon_name, product_name)|
product.price = rand(10...100) + 0.99
product.description = FFaker::Lorem.paragraph
product.available_on = Time.zone.now
- product.option_types = [color, size]
+ if parent_name == 'Women' and %w[Dresses Skirts].include?(taxon_name)
+ product.option_types = [color, length, size]
+ else
+ product.option_types = [color, size]
+ end
product.shipping_category = default_shipping_category
product.tax_category = clothing_tax_category
product.sku = [taxon_name.delete(' '), product_name.delete(' '), product.price].join('_')