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.

Automatically order product option types by position (#12168)

Damian Legawiecd0413b78f885
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb
index b970af6acf..921661b197 100644
--- a/core/app/models/spree/product.rb
+++ b/core/app/models/spree/product.rb
@@ -69,7 +69,7 @@ module Spree
# https://github.com/rails/rails/issues/3458
before_destroy :ensure_not_in_complete_orders
- has_many :product_option_types, dependent: :destroy, inverse_of: :product
+ has_many :product_option_types, -> { order(:position) }, dependent: :destroy, inverse_of: :product
has_many :option_types, through: :product_option_types
has_many :product_properties, dependent: :destroy, inverse_of: :product
has_many :properties, through: :product_properties