spree_core 4.1.6 → 4.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/finders/spree/products/find.rb +26 -4
- data/app/helpers/spree/base_helper.rb +3 -1
- data/app/models/spree/variant.rb +5 -0
- data/lib/spree/core/version.rb +1 -1
- data/spree_core.gemspec +1 -1
- metadata +6 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9abe56060f0568926e082bc13e3984b3819c23f5e5658b14ff58e44589a9e51
|
4
|
+
data.tar.gz: ca29391589cf6bf06c8f20bfb248be16fae419b3fb683255803f01a355f0ddac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2aea90e9694d9b2ac45d23e7a5ea5fd07bc25a7ba93a614328f740857c8c10b6c6d644ff3bc258c3a600f3ae8836e6ad5b1d9473799ffc1c672e7878afd3ff3
|
7
|
+
data.tar.gz: 423b46182c0785e1915315afa475f0125f9d832fcab13ff34abc83f7628681d24d555cc6513b4338c8f282b40f833825b8015502b73162946f908e6535ad5b46
|
@@ -9,6 +9,7 @@ module Spree
|
|
9
9
|
@price = String(params.dig(:filter, :price)).split(',').map(&:to_f)
|
10
10
|
@currency = params[:currency] || current_currency
|
11
11
|
@taxons = taxon_ids(params.dig(:filter, :taxons))
|
12
|
+
@concat_taxons = taxon_ids(params.dig(:filter, :concat_taxons))
|
12
13
|
@name = params.dig(:filter, :name)
|
13
14
|
@options = params.dig(:filter, :options).try(:to_unsafe_hash)
|
14
15
|
@option_value_ids = params.dig(:filter, :option_value_ids)
|
@@ -22,6 +23,7 @@ module Spree
|
|
22
23
|
products = by_skus(products)
|
23
24
|
products = by_price(products)
|
24
25
|
products = by_taxons(products)
|
26
|
+
products = by_concat_taxons(products)
|
25
27
|
products = by_name(products)
|
26
28
|
products = by_options(products)
|
27
29
|
products = by_option_value_ids(products)
|
@@ -34,7 +36,8 @@ module Spree
|
|
34
36
|
|
35
37
|
private
|
36
38
|
|
37
|
-
attr_reader :ids, :skus, :price, :currency, :taxons, :
|
39
|
+
attr_reader :ids, :skus, :price, :currency, :taxons, :concat_taxons, :name, :options,
|
40
|
+
:option_value_ids, :scope, :sort_by, :deleted, :discontinued
|
38
41
|
|
39
42
|
def ids?
|
40
43
|
ids.present?
|
@@ -52,6 +55,10 @@ module Spree
|
|
52
55
|
taxons.present?
|
53
56
|
end
|
54
57
|
|
58
|
+
def concat_taxons?
|
59
|
+
concat_taxons.present?
|
60
|
+
end
|
61
|
+
|
55
62
|
def name?
|
56
63
|
name.present?
|
57
64
|
end
|
@@ -102,6 +109,19 @@ module Spree
|
|
102
109
|
products.joins(:classifications).where(Classification.table_name => { taxon_id: taxons })
|
103
110
|
end
|
104
111
|
|
112
|
+
def by_concat_taxons(products)
|
113
|
+
return products unless concat_taxons?
|
114
|
+
|
115
|
+
product_ids = Spree::Product.
|
116
|
+
joins(:classifications).
|
117
|
+
where(Classification.table_name => { taxon_id: concat_taxons }).
|
118
|
+
group("#{Spree::Product.table_name}.id").
|
119
|
+
having("COUNT(#{Spree::Product.table_name}.id) = ?", concat_taxons.length).
|
120
|
+
ids
|
121
|
+
|
122
|
+
products.where(id: product_ids)
|
123
|
+
end
|
124
|
+
|
105
125
|
def by_name(products)
|
106
126
|
return products unless name?
|
107
127
|
|
@@ -111,9 +131,11 @@ module Spree
|
|
111
131
|
def by_options(products)
|
112
132
|
return products unless options?
|
113
133
|
|
114
|
-
|
115
|
-
|
116
|
-
|
134
|
+
products.where(
|
135
|
+
id: options.map do |key, value|
|
136
|
+
products.with_option_value(key, value).ids
|
137
|
+
end.flatten.compact.uniq
|
138
|
+
)
|
117
139
|
end
|
118
140
|
|
119
141
|
def by_option_value_ids(products)
|
@@ -111,7 +111,9 @@ module Spree
|
|
111
111
|
# we should always try to render image of the default variant
|
112
112
|
# same as it's done on PDP
|
113
113
|
def default_image_for_product(product)
|
114
|
-
if product.
|
114
|
+
if product.images.any?
|
115
|
+
product.images.first
|
116
|
+
elsif product.default_variant.images.any?
|
115
117
|
product.default_variant.images.first
|
116
118
|
elsif product.variant_images.any?
|
117
119
|
product.variant_images.first
|
data/app/models/spree/variant.rb
CHANGED
@@ -102,6 +102,11 @@ module Spree
|
|
102
102
|
|
103
103
|
self.whitelisted_ransackable_associations = %w[option_values product prices default_price]
|
104
104
|
self.whitelisted_ransackable_attributes = %w[weight sku]
|
105
|
+
self.whitelisted_ransackable_scopes = %i(product_name_or_sku_cont)
|
106
|
+
|
107
|
+
def self.product_name_or_sku_cont(query)
|
108
|
+
joins(:product).where("#{Product.table_name}.name LIKE :query OR sku LIKE :query", query: "%#{query}%")
|
109
|
+
end
|
105
110
|
|
106
111
|
def available?
|
107
112
|
!discontinued? && product.available?
|
data/lib/spree/core/version.rb
CHANGED
data/spree_core.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_dependency 'ffaker', '~> 2.9'
|
29
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
|
-
s.add_dependency 'kaminari', '
|
31
|
+
s.add_dependency 'kaminari', '~> 1.2.1'
|
32
32
|
s.add_dependency 'money', '~> 6.13'
|
33
33
|
s.add_dependency 'monetize', '~> 1.9'
|
34
34
|
s.add_dependency 'paranoia', '~> 2.4.2'
|
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.1.
|
4
|
+
version: 4.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -144,22 +144,16 @@ dependencies:
|
|
144
144
|
name: kaminari
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
|
-
- - "
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 1.0.1
|
150
|
-
- - "<"
|
147
|
+
- - "~>"
|
151
148
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.2.
|
149
|
+
version: 1.2.1
|
153
150
|
type: :runtime
|
154
151
|
prerelease: false
|
155
152
|
version_requirements: !ruby/object:Gem::Requirement
|
156
153
|
requirements:
|
157
|
-
- - "
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 1.0.1
|
160
|
-
- - "<"
|
154
|
+
- - "~>"
|
161
155
|
- !ruby/object:Gem::Version
|
162
|
-
version: 1.2.
|
156
|
+
version: 1.2.1
|
163
157
|
- !ruby/object:Gem::Dependency
|
164
158
|
name: money
|
165
159
|
requirement: !ruby/object:Gem::Requirement
|