diff --git a/app/models/spree/product.rb b/app/models/spree/product.rb index fad2d606dd2..606de8cedad 100755 --- a/app/models/spree/product.rb +++ b/app/models/spree/product.rb @@ -39,12 +39,10 @@ class Product < ApplicationRecord has_many :product_properties, dependent: :destroy has_many :properties, through: :product_properties - has_many :variants, -> { order("spree_variants.position ASC") }, class_name: 'Spree::Variant', - dependent: :destroy + has_many :variants, -> { order("spree_variants.id ASC") }, class_name: 'Spree::Variant', + dependent: :destroy - has_many :prices, -> { - order('spree_variants.position, spree_variants.id, currency') - }, through: :variants + has_many :prices, -> { order('spree_variants.id, currency') }, through: :variants has_many :stock_items, through: :variants has_many :supplier_properties, through: :supplier, source: :properties diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index 77ad608b748..dc2be5b5094 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -32,10 +32,8 @@ module Spree end describe 'Variants sorting' do - context 'without master variant' do - it 'sorts variants by position' do - expect(product.variants.to_sql).to match(/ORDER BY spree_variants.position ASC/) - end + it 'sorts variants by id' do + expect(product.variants.to_sql).to match(/ORDER BY spree_variants.id ASC/) end end end