Class: Spree::Products::Sort

Inherits:
BaseSorter show all
Defined in:
app/sorters/spree/products/sort.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope, current_currency, params = {}, allowed_sort_attributes = []) ⇒ Sort

Returns a new instance of Sort.



4
5
6
7
# File 'app/sorters/spree/products/sort.rb', line 4

def initialize(scope, current_currency, params = {}, allowed_sort_attributes = [])
  super(scope, params, allowed_sort_attributes)
  @currency = params[:currency] || current_currency
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
# File 'app/sorters/spree/products/sort.rb', line 9

def call
  products = by_param_attributes(scope)
  products = by_price(products)
  products = by_sku(products)

  products = select_translatable_fields(products)

  products.distinct
end