spree_core 4.1.5 → 4.1.6
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 +20 -7
- data/app/helpers/spree/products_helper.rb +15 -14
- data/app/models/concerns/spree/product_scopes.rb +2 -2
- data/app/models/spree/product.rb +2 -2
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +1 -1
- data/app/models/spree/taxon.rb +6 -0
- data/lib/spree/core/version.rb +1 -1
- data/spree_core.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96827f4cde98df9373667a89b28276d3ffc954bf7e2c25fb33d1675012c518ef
|
4
|
+
data.tar.gz: c84bd003851d88dae731ac73e31041a9fd0a523357c3b48476686935cdf7b070
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8aba081fef39e67d547ca039dcf20477d10388a9c382e8f368b4be2ed0e86496f96b86b557f400bdcece01a86f29c09868f7176442875bd6fc79ea2843c729d
|
7
|
+
data.tar.gz: 565ba5fe5695eada6e6b0e530ae318be22b1105200d8138595a17b39eef1ed4e0d4e1a8ccdd65e7b4b6ac349394bad2a78e18eee932ed5bbc19284e49b562f48
|
@@ -99,7 +99,7 @@ module Spree
|
|
99
99
|
def by_taxons(products)
|
100
100
|
return products unless taxons?
|
101
101
|
|
102
|
-
products.joins(:
|
102
|
+
products.joins(:classifications).where(Classification.table_name => { taxon_id: taxons })
|
103
103
|
end
|
104
104
|
|
105
105
|
def by_name(products)
|
@@ -142,13 +142,25 @@ module Spree
|
|
142
142
|
|
143
143
|
case sort_by
|
144
144
|
when 'default'
|
145
|
-
|
145
|
+
if taxons?
|
146
|
+
products.
|
147
|
+
select("#{Product.table_name}.*, #{Classification.table_name}.position").
|
148
|
+
order("#{Classification.table_name}.position" => :asc)
|
149
|
+
else
|
150
|
+
products
|
151
|
+
end
|
146
152
|
when 'newest-first'
|
147
153
|
products.order(available_on: :desc)
|
148
154
|
when 'price-high-to-low'
|
149
|
-
products.
|
155
|
+
products.
|
156
|
+
select("#{Product.table_name}.*, #{Spree::Price.table_name}.amount").
|
157
|
+
reorder('').
|
158
|
+
send(:descend_by_master_price)
|
150
159
|
when 'price-low-to-high'
|
151
|
-
products.
|
160
|
+
products.
|
161
|
+
select("#{Product.table_name}.*, #{Spree::Price.table_name}.amount").
|
162
|
+
reorder('').
|
163
|
+
send(:ascend_by_master_price)
|
152
164
|
end
|
153
165
|
end
|
154
166
|
|
@@ -160,10 +172,11 @@ module Spree
|
|
160
172
|
discontinued ? products : products.available
|
161
173
|
end
|
162
174
|
|
163
|
-
def taxon_ids(
|
164
|
-
return
|
175
|
+
def taxon_ids(taxons_ids)
|
176
|
+
return if taxons_ids.nil? || taxons_ids.to_s.blank?
|
165
177
|
|
166
|
-
|
178
|
+
taxons = Spree::Taxon.where(id: taxons_ids.to_s.split(','))
|
179
|
+
taxons.map(&:cached_self_and_descendants_ids).flatten.compact.uniq.map(&:to_s)
|
167
180
|
end
|
168
181
|
end
|
169
182
|
end
|
@@ -67,7 +67,7 @@ module Spree
|
|
67
67
|
cache_key_elements = common_product_cache_keys
|
68
68
|
cache_key_elements += [
|
69
69
|
product.cache_key_with_version,
|
70
|
-
product.possible_promotions
|
70
|
+
product.possible_promotions.map(&:cache_key)
|
71
71
|
]
|
72
72
|
|
73
73
|
cache_key_elements.compact.join('/')
|
@@ -79,8 +79,9 @@ module Spree
|
|
79
79
|
string.slice(0..449) + '...'
|
80
80
|
end
|
81
81
|
|
82
|
-
|
83
|
-
|
82
|
+
# will return a human readable string
|
83
|
+
def available_status(product)
|
84
|
+
return Spree.t(:discontinued) if product.discontinued?
|
84
85
|
return Spree.t(:deleted) if product.deleted?
|
85
86
|
|
86
87
|
if product.available?
|
@@ -116,16 +117,16 @@ module Spree
|
|
116
117
|
def related_products
|
117
118
|
return [] unless @product.respond_to?(:has_related_products?) && @product.has_related_products?(:related_products)
|
118
119
|
|
119
|
-
@
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
120
|
+
@related_products ||= @product.
|
121
|
+
related_products.
|
122
|
+
includes(
|
123
|
+
:tax_category,
|
124
|
+
master: [
|
125
|
+
:prices,
|
126
|
+
images: { attachment_attachment: :blob },
|
127
|
+
]
|
128
|
+
).
|
129
|
+
limit(Spree::Config[:products_per_page])
|
129
130
|
end
|
130
131
|
|
131
132
|
def product_available_in_currency?
|
@@ -145,7 +146,7 @@ module Spree
|
|
145
146
|
end
|
146
147
|
|
147
148
|
def variants_option_types_presenter(variants, product)
|
148
|
-
@
|
149
|
+
@variants_option_types_presenter ||= begin
|
149
150
|
option_types = Spree::Variants::OptionTypesFinder.new(variant_ids: variants.map(&:id)).execute
|
150
151
|
|
151
152
|
Spree::Variants::OptionTypesPresenter.new(option_types, variants, product)
|
@@ -81,7 +81,7 @@ module Spree
|
|
81
81
|
# SELECT COUNT(*) ...
|
82
82
|
add_search_scope :in_taxon do |taxon|
|
83
83
|
includes(:classifications).
|
84
|
-
where('spree_products_taxons.taxon_id' => taxon.
|
84
|
+
where('spree_products_taxons.taxon_id' => taxon.cached_self_and_descendants_ids).
|
85
85
|
order('spree_products_taxons.position ASC')
|
86
86
|
end
|
87
87
|
|
@@ -221,7 +221,7 @@ module Spree
|
|
221
221
|
|
222
222
|
# specifically avoid having an order for taxon search (conflicts with main order)
|
223
223
|
def self.prepare_taxon_conditions(taxons)
|
224
|
-
ids = taxons.map
|
224
|
+
ids = taxons.map(&:cached_self_and_descendants_ids).flatten.uniq
|
225
225
|
joins(:classifications).where(Classification.table_name => { taxon_id: ids })
|
226
226
|
end
|
227
227
|
private_class_method :prepare_taxon_conditions
|
data/app/models/spree/product.rb
CHANGED
@@ -111,7 +111,7 @@ module Spree
|
|
111
111
|
|
112
112
|
alias options product_option_types
|
113
113
|
|
114
|
-
self.whitelisted_ransackable_associations = %w[stores variants_including_master master variants]
|
114
|
+
self.whitelisted_ransackable_associations = %w[taxons stores variants_including_master master variants]
|
115
115
|
self.whitelisted_ransackable_attributes = %w[description name slug discontinue_on]
|
116
116
|
self.whitelisted_ransackable_scopes = %w[not_discontinued]
|
117
117
|
|
@@ -341,7 +341,7 @@ module Spree
|
|
341
341
|
price: master.price
|
342
342
|
)
|
343
343
|
end
|
344
|
-
|
344
|
+
save
|
345
345
|
end
|
346
346
|
|
347
347
|
def ensure_master
|
@@ -23,7 +23,7 @@ module Spree
|
|
23
23
|
order = line_item.order
|
24
24
|
|
25
25
|
# Prevent negative order totals
|
26
|
-
amounts << order.amount - order.adjustments.sum(:amount).abs if order.adjustments.any?
|
26
|
+
amounts << order.amount - order.adjustments.eligible.sum(:amount).abs if order.adjustments.eligible.any?
|
27
27
|
|
28
28
|
amounts.min * -1
|
29
29
|
end
|
data/app/models/spree/taxon.rb
CHANGED
@@ -74,6 +74,12 @@ module Spree
|
|
74
74
|
ancestor_chain + name.to_s
|
75
75
|
end
|
76
76
|
|
77
|
+
def cached_self_and_descendants_ids
|
78
|
+
Rails.cache.fetch("#{cache_key_with_version}/descendant-ids") do
|
79
|
+
self_and_descendants.ids
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
77
83
|
# awesome_nested_set sorts by :lft and :rgt. This call re-inserts the child
|
78
84
|
# node so that its resulting position matches the observable 0-indexed position.
|
79
85
|
# ** Note ** no :position column needed - a_n_s doesn't handle the reordering if
|
data/lib/spree/core/version.rb
CHANGED
data/spree_core.gemspec
CHANGED
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
s.add_dependency 'state_machines-activerecord', '~> 0.6'
|
40
40
|
s.add_dependency 'state_machines-activemodel', '~> 0.7'
|
41
41
|
s.add_dependency 'stringex'
|
42
|
-
s.add_dependency 'twitter_cldr', '>= 4.3', '<
|
42
|
+
s.add_dependency 'twitter_cldr', '>= 4.3', '< 7.0'
|
43
43
|
s.add_dependency 'sprockets', '~> 3.7'
|
44
44
|
s.add_dependency 'sprockets-rails'
|
45
45
|
s.add_dependency 'mini_magick', '>= 4.9.4', '< 4.11.0'
|
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.6
|
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-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -309,7 +309,7 @@ dependencies:
|
|
309
309
|
version: '4.3'
|
310
310
|
- - "<"
|
311
311
|
- !ruby/object:Gem::Version
|
312
|
-
version: '
|
312
|
+
version: '7.0'
|
313
313
|
type: :runtime
|
314
314
|
prerelease: false
|
315
315
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -319,7 +319,7 @@ dependencies:
|
|
319
319
|
version: '4.3'
|
320
320
|
- - "<"
|
321
321
|
- !ruby/object:Gem::Version
|
322
|
-
version: '
|
322
|
+
version: '7.0'
|
323
323
|
- !ruby/object:Gem::Dependency
|
324
324
|
name: sprockets
|
325
325
|
requirement: !ruby/object:Gem::Requirement
|