Module: SpreeMobility::CoreExt::Spree::ProductScopesWithMobilityDecorator
- Defined in:
- lib/spree_mobility/core_ext/spree/product_scopes_with_mobility_decorator.rb
Instance Method Summary collapse
Instance Method Details
#ascend_by_taxons_min_position(taxon_ids) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/spree_mobility/core_ext/spree/product_scopes_with_mobility_decorator.rb', line 2 def ascend_by_taxons_min_position(taxon_ids) # order() must not refer to select(), because select could be removed # in Spree::Products::Find joins(:classifications). where(::Spree::Classification.table_name => { taxon_id: taxon_ids }). select( [ "#{::Spree::Product.table_name}.*", "MIN(#{::Spree::Classification.table_name}.position) AS min_position" ].join(', ') ). group(:id). order(Arel.sql("MIN(#{::Spree::Classification.table_name}.position) ASC")) end |