spree_core 4.0.0.rc2 → 4.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/finders/spree/products/find.rb +43 -10
- data/app/finders/spree/taxons/find.rb +5 -6
- data/lib/spree/core/version.rb +1 -1
- data/spree_core.gemspec +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a92eeda37655c24a7921c434a9e7cef57121e16da3457279999d2011f898bea8
|
4
|
+
data.tar.gz: 85dc63ab6533ea10eb138804558df376e33f1bfe24e0345d5209665a76c3b724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 368d97922da6dbda108e121097efce68a7393b556a0f3c0d8504db6158be11a42a1177d5a85e77c43d01d29de224f45666928a00ab0e3865274e44c0cb50b4fa
|
7
|
+
data.tar.gz: 3298b2b794cae1e7c9b8653c581af1d7bb5077cc8a7b199644657b903597f807ec2c8cf2312f78a5a88f01d1c06905016dcd5948bdab77ec000b38ae7e0b79f0
|
@@ -4,15 +4,17 @@ module Spree
|
|
4
4
|
def initialize(scope:, params:, current_currency:)
|
5
5
|
@scope = scope
|
6
6
|
|
7
|
-
@ids
|
8
|
-
@skus
|
9
|
-
@price
|
10
|
-
@currency
|
11
|
-
@taxons
|
12
|
-
@name
|
13
|
-
@options
|
14
|
-
@
|
15
|
-
@
|
7
|
+
@ids = String(params.dig(:filter, :ids)).split(',')
|
8
|
+
@skus = String(params.dig(:filter, :skus)).split(',')
|
9
|
+
@price = String(params.dig(:filter, :price)).split(',').map(&:to_f)
|
10
|
+
@currency = params[:currency] || current_currency
|
11
|
+
@taxons = String(params.dig(:filter, :taxons)).split(',')
|
12
|
+
@name = params.dig(:filter, :name)
|
13
|
+
@options = params.dig(:filter, :options).try(:to_unsafe_hash)
|
14
|
+
@option_value_ids = params.dig(:filter, :option_value_ids)
|
15
|
+
@sort_by = params.dig(:sort_by)
|
16
|
+
@deleted = params.dig(:filter, :show_deleted)
|
17
|
+
@discontinued = params.dig(:filter, :show_discontinued)
|
16
18
|
end
|
17
19
|
|
18
20
|
def execute
|
@@ -22,15 +24,17 @@ module Spree
|
|
22
24
|
products = by_taxons(products)
|
23
25
|
products = by_name(products)
|
24
26
|
products = by_options(products)
|
27
|
+
products = by_option_value_ids(products)
|
25
28
|
products = include_deleted(products)
|
26
29
|
products = include_discontinued(products)
|
30
|
+
products = ordered(products)
|
27
31
|
|
28
32
|
products
|
29
33
|
end
|
30
34
|
|
31
35
|
private
|
32
36
|
|
33
|
-
attr_reader :ids, :skus, :price, :currency, :taxons, :name, :options, :scope, :deleted, :discontinued
|
37
|
+
attr_reader :ids, :skus, :price, :currency, :taxons, :name, :options, :option_value_ids, :scope, :sort_by, :deleted, :discontinued
|
34
38
|
|
35
39
|
def ids?
|
36
40
|
ids.present?
|
@@ -56,6 +60,14 @@ module Spree
|
|
56
60
|
options.present?
|
57
61
|
end
|
58
62
|
|
63
|
+
def option_value_ids?
|
64
|
+
option_value_ids.present?
|
65
|
+
end
|
66
|
+
|
67
|
+
def sort_by?
|
68
|
+
sort_by.present?
|
69
|
+
end
|
70
|
+
|
59
71
|
def name_matcher
|
60
72
|
Spree::Product.arel_table[:name].matches("%#{name}%")
|
61
73
|
end
|
@@ -105,6 +117,27 @@ module Spree
|
|
105
117
|
end.inject(:&)
|
106
118
|
end
|
107
119
|
|
120
|
+
def by_option_value_ids(products)
|
121
|
+
return products unless option_value_ids?
|
122
|
+
|
123
|
+
products.joins(variants: :option_values).distinct.where(spree_option_values: { id: option_value_ids })
|
124
|
+
end
|
125
|
+
|
126
|
+
def ordered(products)
|
127
|
+
return products unless sort_by?
|
128
|
+
|
129
|
+
case sort_by
|
130
|
+
when 'default'
|
131
|
+
products
|
132
|
+
when 'newest-first'
|
133
|
+
products.order(available_on: :desc)
|
134
|
+
when 'price-high-to-low'
|
135
|
+
products.select('spree_products.*, spree_prices.amount').reorder('').send(:descend_by_master_price)
|
136
|
+
when 'price-low-to-high'
|
137
|
+
products.select('spree_products.*, spree_prices.amount').reorder('').send(:ascend_by_master_price)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
108
141
|
def include_deleted(products)
|
109
142
|
deleted ? products.with_deleted : products.not_deleted
|
110
143
|
end
|
@@ -3,12 +3,11 @@ module Spree
|
|
3
3
|
class Find
|
4
4
|
def initialize(scope:, params:)
|
5
5
|
@scope = scope
|
6
|
-
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@roots = params[:roots]
|
6
|
+
@ids = String(params.dig(:filter, :ids)).split(',')
|
7
|
+
@parent = params.dig(:filter, :parent_id)
|
8
|
+
@taxonomy = params.dig(:filter, :taxonomy_id)
|
9
|
+
@name = params.dig(:filter, :name)
|
10
|
+
@roots = params.dig(:filter, :roots)
|
12
11
|
end
|
13
12
|
|
14
13
|
def execute
|
data/lib/spree/core/version.rb
CHANGED
data/spree_core.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_dependency 'carmen', '>= 1.0', '< 1.2'
|
27
27
|
s.add_dependency 'cancancan', '~> 3.0'
|
28
28
|
s.add_dependency 'ffaker', '~> 2.9'
|
29
|
-
s.add_dependency 'friendly_id', '
|
29
|
+
s.add_dependency 'friendly_id', '>= 5.2.1', '< 5.4.0'
|
30
30
|
s.add_dependency 'highline', '~> 2.0.0' # Necessary for the install generator
|
31
31
|
s.add_dependency 'kaminari', '>= 1.0.1', '< 1.2.0'
|
32
32
|
s.add_dependency 'money', '~> 6.13'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -110,16 +110,22 @@ dependencies:
|
|
110
110
|
name: friendly_id
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- - "
|
113
|
+
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: 5.2.1
|
116
|
+
- - "<"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 5.4.0
|
116
119
|
type: :runtime
|
117
120
|
prerelease: false
|
118
121
|
version_requirements: !ruby/object:Gem::Requirement
|
119
122
|
requirements:
|
120
|
-
- - "
|
123
|
+
- - ">="
|
121
124
|
- !ruby/object:Gem::Version
|
122
125
|
version: 5.2.1
|
126
|
+
- - "<"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 5.4.0
|
123
129
|
- !ruby/object:Gem::Dependency
|
124
130
|
name: highline
|
125
131
|
requirement: !ruby/object:Gem::Requirement
|