From 4dc9d16e6c862718e9b998d9c2286d1d9d1a423c Mon Sep 17 00:00:00 2001 From: Ishank Gupta Date: Sat, 5 Jul 2014 01:33:05 +0530 Subject: [PATCH] Fixed sorting issue with products Products were not sorted as per the results from the SOLR hit, added ordering in the product to fix the issue --- lib/spree/sunspot/search.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spree/sunspot/search.rb b/lib/spree/sunspot/search.rb index 8d0f527..b97ae97 100644 --- a/lib/spree/sunspot/search.rb +++ b/lib/spree/sunspot/search.rb @@ -92,7 +92,7 @@ def get_products_conditions_for(base_scope, query) @solr_search.execute if @solr_search.total > 0 @hits = @solr_search.hits.collect{|hit| hit.primary_key.to_i} - base_scope = base_scope.where( ["#{Spree::Product.table_name}.id in (?)", @hits] ) + base_scope = base_scope.where( ["#{Spree::Product.table_name}.id in (?)", @hits] ).order("FIELD(#{Spree::Product.table_name}.id, #{@hits.join(',')})") else base_scope = base_scope.where( ["#{Spree::Product.table_name}.id = -1"] ) end