diff --git a/lib/tasks/sample_data/product_factory.rb b/lib/tasks/sample_data/product_factory.rb index 01e92dddb7..9d5411bef5 100644 --- a/lib/tasks/sample_data/product_factory.rb +++ b/lib/tasks/sample_data/product_factory.rb @@ -72,10 +72,18 @@ class ProductFactory variant_unit: "weight", variant_unit_scale: 1, unit_value: 1, - shipping_category: DefaultShippingCategory.find_or_create + shipping_category: DefaultShippingCategory.find_or_create, + tax_category_id: find_or_create_tax_category.id ) product = Spree::Product.create_with(params).find_or_create_by_name!(params[:name]) product.variants.first.update_attribute :on_demand, true product end + + def find_or_create_tax_category + tax_category_name = "Tax Category" + tax_category = Spree::TaxCategory.find_by_name(tax_category_name) + tax_category ||= Spree::TaxCategory.create!(name: tax_category_name) + tax_category + end end