Permalink
Browse files

Search for Spree 1.2 updated logic

  • Loading branch information...
1 parent f7e7163 commit f1686224cd26470803e4cf1ec697decfc8851304 @j15e j15e committed Mar 4, 2013
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/spree/core/search/base_decorator.rb
View
14 lib/spree/core/search/base_decorator.rb
@@ -1,12 +1,16 @@
Spree::Core::Search::Base.class_eval do
def get_products_conditions_for(base_scope, query)
- conditions = []
- query.split.each do |keyword|
- conditions << [:name, :description].map do |field|
- "spree_product_translations.#{field} LIKE '%#{keyword}%'"
+ if query.blank?
+ base_scope
+ else
+ conditions = []
+ query.split.each do |keyword|
+ conditions << [:name, :description].map do |field|
+ "spree_product_translations.#{field} LIKE '%#{keyword}%'"
+ end
end
+ base_scope.where(conditions.join(' OR '))
end
- base_scope.where(conditions.join(' OR '))
end
protected

0 comments on commit f168622

Please sign in to comment.