Class: Spree::Products::Find
- Inherits:
-
Object
- Object
- Spree::Products::Find
- Defined in:
- app/finders/spree/products/find.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(scope:, params:, current_currency: nil) ⇒ Find
constructor
A new instance of Find.
Constructor Details
#initialize(scope:, params:, current_currency: nil) ⇒ Find
Returns a new instance of Find.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/finders/spree/products/find.rb', line 4 def initialize(scope:, params:, current_currency: nil) @scope = scope if current_currency.present? ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller) `current_currency` param is deprecated and will be removed in Spree 5. Please pass `:currency` in `params` hash instead. DEPRECATION end @ids = String(params.dig(:filter, :ids)).split(',') @skus = String(params.dig(:filter, :skus)).split(',') @store = params[:store] || Spree::Store.default @price = map_prices(String(params.dig(:filter, :price)).split(',')) @currency = current_currency || params.dig(:filter, :currency) || params[:currency] @taxons = taxon_ids(params.dig(:filter, :taxons)) @concat_taxons = taxon_ids(params.dig(:filter, :concat_taxons)) @name = params.dig(:filter, :name) @options = params.dig(:filter, :options).try(:to_unsafe_hash) @option_value_ids = params.dig(:filter, :option_value_ids) @sort_by = params.dig(:sort_by) @deleted = params.dig(:filter, :show_deleted) @discontinued = params.dig(:filter, :show_discontinued) @properties = params.dig(:filter, :properties) @in_stock = params.dig(:filter, :in_stock) @backorderable = params.dig(:filter, :backorderable) @purchasable = params.dig(:filter, :purchasable) end |
Instance Method Details
#execute ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/finders/spree/products/find.rb', line 33 def execute products = by_ids(scope) products = by_skus(products) products = by_price(products) products = by_currency(products) products = by_taxons(products) products = by_concat_taxons(products) products = by_name(products) products = (products) products = by_option_value_ids(products) products = by_properties(products) products = include_deleted(products) products = include_discontinued(products) products = show_only_stock(products) products = show_only_backorderable(products) products = show_only_purchasable(products) products = ordered(products) products.distinct end |