<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/controllers/taxons_controller.rb</filename>
    </added>
    <added>
      <filename>app/helpers/application_helper.rb</filename>
    </added>
    <added>
      <filename>app/helpers/taxons_helper.rb</filename>
    </added>
    <added>
      <filename>app/views/products/index.html.erb</filename>
    </added>
    <added>
      <filename>app/views/shared/_login_bar.html.erb</filename>
    </added>
    <added>
      <filename>app/views/taxons/show.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,82 +1,33 @@
 class ProductsController &lt; Spree::BaseController
-# Uncomment those methods to make the simple search work for products and inside taxons
-      private
-
-      def collection
-        products_per_page = 20
-
-        search = Search.new({
-          :taxon_id =&gt; params[:taxon],
-          :min_price =&gt; params[:min_price],
-          :max_price =&gt; params[:max_price],
-          :keywords =&gt; params[:search]
-        })
-        # Verify if theres any ondition.
-        conditions = search.conditions
-        if conditions == [&quot;&quot;]
-          conditions = &quot;&quot;
-        end
-
-        # Define what is allowed.
-        sort_params = {
-          &quot;price_asc&quot; =&gt; &quot;master_price ASC&quot;,
-          &quot;price_desc&quot; =&gt; &quot;master_price DESC&quot;,
-          &quot;date_asc&quot; =&gt; &quot;available_on ASC&quot;,
-          &quot;date_desc&quot; =&gt; &quot;available_on DESC&quot;,
-          &quot;name_asc&quot; =&gt; &quot;name ASC&quot;,
-          &quot;name_desc&quot; =&gt; &quot;name DESC&quot;
-        }
-        # Set it to what is allowed or default.
-        @sort_by = sort_params[params[:sort]] || &quot;available_on DESC&quot;
-
-        @search_param = &quot;- #{t('ext.search.searching_by', :search_term =&gt; params[:search])}&quot; if params[:search]
-
-        @collection ||= Product.active.by_name(params[:search]).find(
-          :all,
-          :conditions =&gt; conditions,
-          :order =&gt; @sort_by,
-          :page =&gt; {:start =&gt; 1, :size =&gt; products_per_page, :current =&gt; params[:p]},
-          :include =&gt; :images)
-      end
-    end
-
-    TaxonsController.class_eval do
-      private
-
-      def load_data
-        products_per_page = 20
-
-        search = Search.new({
-          :taxon_id =&gt; params[:taxon],
-          :min_price =&gt; params[:min_price],
-          :max_price =&gt; params[:max_price],
-          :keywords =&gt; params[:search]
-        })
-        # Verify if theres any ondition.
-        conditions = search.conditions
-        if conditions == [&quot;&quot;]
-          conditions = &quot;&quot;
-        end
-
-        # Define what is allowed.
-        sort_params = {
-          &quot;price_asc&quot; =&gt; &quot;master_price ASC&quot;,
-          &quot;price_desc&quot; =&gt; &quot;master_price DESC&quot;,
-          &quot;date_asc&quot; =&gt; &quot;available_on ASC&quot;,
-          &quot;date_desc&quot; =&gt; &quot;available_on DESC&quot;,
-          &quot;name_asc&quot; =&gt; &quot;name ASC&quot;,
-          &quot;name_desc&quot; =&gt; &quot;name DESC&quot;
-        }
-        # Set it to what is allowed or default.
-        @sort_by = sort_params[params[:sort]] || &quot;available_on DESC&quot;
-
-        @search_param = &quot;- #{t('ext.search.searching_by', :search_term =&gt; params[:search])}&quot; if params[:search]
-
-        @products ||= object.products.active.by_name(params[:search]).find(
-          :all,
-          :conditions =&gt; conditions,
-          :order =&gt; @sort_by,
-          :page =&gt; {:start =&gt; 1, :size =&gt; products_per_page, :current =&gt; params[:p]},
-          :include =&gt; :images)
-      end
+# Uncomment this method to make the simple search work for products.
+  private
+
+  def collection
+    # Define what is allowed.
+    sort_params = {
+      &quot;price_asc&quot; =&gt; [&quot;master_price&quot;, &quot;ASC&quot;],
+      &quot;price_desc&quot; =&gt; [&quot;master_price&quot;, &quot;DESC&quot;],
+      &quot;date_asc&quot; =&gt; [&quot;available_on&quot;, &quot;ASC&quot;],
+      &quot;date_desc&quot; =&gt; [&quot;available_on&quot;, &quot;DESC&quot;],
+      &quot;name_asc&quot; =&gt; [&quot;name&quot;, &quot;ASC&quot;],
+      &quot;name_desc&quot; =&gt; [&quot;name&quot;, &quot;DESC&quot;]
+    }
+    # Set it to what is allowed or default.
+    @sort_by_and_as = sort_params[params[:sort]] || [&quot;available_on&quot;, &quot;DESC&quot;]
+    # If setted to default, clean the param it doesn't need to clutter the url.
+    params[:sort] = nil if @sort_by_and_as == [&quot;available_on&quot;, &quot;DESC&quot;]
+
+#    @search_param = &quot;- #{t('ext.search.searching_by', :search_term =&gt; params[:keywords])}&quot; if params[:keywords]
+
+    @search = Product.active.new_search(params[:search])
+    @search.order_by = @sort_by_and_as[0]
+    @search.order_as = @sort_by_and_as[1]
+    @search.conditions.name_contains = params[:keywords]
+
+    @search.per_page = Spree::Config[:products_per_page]
+    @search.include = :images
+
+    @product_cols = 3
+    @products ||= @search.all
+  end
 end</diff>
      <filename>app/controllers/products_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,14 +5,16 @@ class SearchesController &lt; Spree::BaseController
   def test
   end
   
+  # Create a search object to receive parameters of the form to validate.
   def new
     @search = Search.new
   end
   
+  # Validates the search object and redirect to show action renaming the parameters to not clash with searchlogic.
   def create
     @search = Search.new(params[:search])
     if @search.valid?
-      
+
       # Build the custom parameters hash and don't clutter the url with empty params.
       temp = {}
       temp.merge!(:taxon =&gt; params[&quot;search&quot;][&quot;taxon_id&quot;]) if !params[&quot;search&quot;][&quot;taxon_id&quot;].empty?
@@ -20,7 +22,7 @@ class SearchesController &lt; Spree::BaseController
       temp.merge!(:min_price =&gt; params[&quot;search&quot;][&quot;min_price&quot;]) if !params[&quot;search&quot;][&quot;min_price&quot;].empty?
       temp.merge!(:max_price =&gt; params[&quot;search&quot;][&quot;max_price&quot;]) if !params[&quot;search&quot;][&quot;max_price&quot;].empty?
       temp.merge!(:keywords =&gt; params[&quot;search&quot;][&quot;keywords&quot;]) if !params[&quot;search&quot;][&quot;keywords&quot;].empty?
-      
+
       redirect_to temp.merge(:action =&gt; 'show')
     else
       render :action =&gt; 'new'
@@ -28,76 +30,50 @@ class SearchesController &lt; Spree::BaseController
   end
   
   def show
-    products_per_page = 4
-
-    @search = Search.new({
-      :taxon_id =&gt; params[:taxon],
-      :subtaxons =&gt; params[:subtaxons],
-      :min_price =&gt; params[:min_price],
-      :max_price =&gt; params[:max_price],
-      :keywords =&gt; params[:keywords]
-    })
-    # Verify if theres any ondition.
-    conditions = @search.conditions
-    if conditions == [&quot;&quot;]
-      conditions = &quot;&quot;
-    end
-
-
     # Define what is allowed.
     sort_params = {
-      &quot;price_asc&quot; =&gt; &quot;master_price ASC&quot;,
-      &quot;price_desc&quot; =&gt; &quot;master_price DESC&quot;,
-      &quot;date_asc&quot; =&gt; &quot;available_on ASC&quot;,
-      &quot;date_desc&quot; =&gt; &quot;available_on DESC&quot;,
-      &quot;name_asc&quot; =&gt; &quot;name ASC&quot;,
-      &quot;name_desc&quot; =&gt; &quot;name DESC&quot;
+      &quot;price_asc&quot; =&gt; [&quot;master_price&quot;, &quot;ASC&quot;],
+      &quot;price_desc&quot; =&gt; [&quot;master_price&quot;, &quot;DESC&quot;],
+      &quot;date_asc&quot; =&gt; [&quot;available_on&quot;, &quot;ASC&quot;],
+      &quot;date_desc&quot; =&gt; [&quot;available_on&quot;, &quot;DESC&quot;],
+      &quot;name_asc&quot; =&gt; [&quot;name&quot;, &quot;ASC&quot;],
+      &quot;name_desc&quot; =&gt; [&quot;name&quot;, &quot;DESC&quot;]
     }
     # Set it to what is allowed or default.
-    @sort_by = sort_params[params[:sort]] || &quot;available_on DESC&quot;
-    
-    @search_param = &quot;- #{t('ext.search.searching_by', :search_term =&gt; params[:search])}&quot; if params[:search]
+    @sort_by_and_as = sort_params[params[:sort]] || [&quot;available_on&quot;, &quot;DESC&quot;]
+    # If setted to default, clean the param it doesn't need to clutter the url.
+    params[:sort] = nil if @sort_by_and_as == [&quot;available_on&quot;, &quot;DESC&quot;]
+
+#    @search_param = &quot;- #{t('ext.search.searching_by', :search_term =&gt; params[:keywords])}&quot; if params[:keywords]
+
+
+    @search = Product.active.new_search(params[:search])
 
-    an_array = []
-    add_subtaxons(an_array, Taxon.find(@search.taxon_id)) if @search.taxon_id
-    
-    count_query = &quot;
-      SELECT count(products.id) FROM products
-      INNER JOIN products_taxons ON (products.id = products_taxons.product_id)
-      INNER JOIN taxons ON (products_taxons.taxon_id = taxons.id)
-      WHERE taxons.id IN (#{an_array.join(',').to_s})
-      #{(conditions.empty? ? &quot;&quot; : &quot; AND &quot;)} #{conditions}&quot;
-            
-    query = &quot;
-      SELECT products.* FROM products
-      INNER JOIN products_taxons ON (products.id = products_taxons.product_id)
-      INNER JOIN taxons ON (products_taxons.taxon_id = taxons.id)
-      WHERE taxons.id IN (#{an_array.join(',').to_s})
-      #{(conditions.empty? ? &quot;&quot; : &quot; AND &quot;)} #{conditions} ORDER BY #{@sort_by}&quot;
- 
- 
-    if @search.taxon_id
-      if @search.subtaxons
-        @products ||= Product.paginating_sql_find(
-          count_query, query, {:page_size =&gt; products_per_page, :current =&gt; params[:p]}
-        )
+    if params[:taxon]
+      if params[:subtaxons]
+        an_array = []
+
+        a_taxon = Taxon.first(:conditions =&gt; {:id_is =&gt; params[:taxon]})
+        add_subtaxons(an_array, a_taxon) if a_taxon
+
+        @search.conditions.taxons.id_equals = an_array
       else
-        @products ||= Taxon.find(@search.taxon_id).products.available.find(
-          :all,
-          :conditions =&gt; conditions,
-          :order =&gt; @sort_by,
-          :page =&gt; {:start =&gt; 1, :size =&gt; products_per_page, :current =&gt; params[:p]},
-          :include =&gt; :images)
+        @search.conditions.taxons.id_equals = params[:taxon]
       end
-    else
-      @products ||= Product.available.by_name(params[:search]).find(
-        :all,
-        :conditions =&gt; conditions,
-        :order =&gt; @sort_by,
-        :page =&gt; {:start =&gt; 1, :size =&gt; products_per_page, :current =&gt; params[:p]},
-        :include =&gt; :images)
     end
-  end
+
+
+    @search.order_by = @sort_by_and_as[0]
+    @search.order_as = @sort_by_and_as[1]
+    @search.conditions.name_contains = params[:keywords]
+    @search.conditions.master_price_greater_than_or_equal_to = params[:min_price]
+    @search.conditions.master_price_less_than_or_equal_to = params[:max_price]
+    @search.per_page = Spree::Config[:products_per_page]
+    @search.include = :images
+
+    @product_cols = 3
+    @products ||= @search.all
+end
 
 
   private</diff>
      <filename>app/controllers/searches_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,16 +2,32 @@ module SearchesHelper
 
   # Redefined here to not escape html characters inside the select options, we need to add &amp;nbsp; tags
   # there to change indentation of subitems.
-  def options_for_select(container, selected = nil)
+#  def options_for_select(container, selected = nil)
+#    container = container.to_a if Hash === container
+#
+#    options_for_select = container.inject([]) do |options, element|
+#      text, value = option_text_and_value(element)
+#      selected_attribute = ' selected=&quot;selected&quot;' if option_value_selected?(value, selected)
+#      options &lt;&lt; %(&lt;option value=&quot;#{html_escape(value.to_s)}&quot;#{selected_attribute}&gt;#{text.to_s}&lt;/option&gt;)
+#    end
+#
+#    options_for_select.join(&quot;\n&quot;)
+#  end
+
+  # Redefined here to not escape html characters inside the select options, we need to add &amp;nbsp; tags
+  # there to change indentation of subitems. Changed version to fit option_tags_with_disable plugin.
+  def options_for_select(container, selected = nil, disabled = nil)
     container = container.to_a if Hash === container
-  
+
     options_for_select = container.inject([]) do |options, element|
       text, value = option_text_and_value(element)
       selected_attribute = ' selected=&quot;selected&quot;' if option_value_selected?(value, selected)
-      options &lt;&lt; %(&lt;option value=&quot;#{html_escape(value.to_s)}&quot;#{selected_attribute}&gt;#{text.to_s}&lt;/option&gt;)
+      disabled_attribute = ' disabled=&quot;disabled&quot;' if option_value_selected?(value, disabled) &amp;&amp; disabled != nil
+      options &lt;&lt; %(&lt;option value=&quot;#{html_escape(value.to_s)}&quot;#{selected_attribute}#{disabled_attribute}&gt;#{text.to_s}&lt;/option&gt;)
     end
-  
+
     options_for_select.join(&quot;\n&quot;)
   end
 
+
 end</diff>
      <filename>app/helpers/searches_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,35 +9,4 @@ class Search &lt; ActiveRecord::Base
 
   validates_numericality_of :min_price, :unless =&gt; Proc.new { |search| search.min_price.nil? }
   validates_numericality_of :max_price, :unless =&gt; Proc.new { |search| search.max_price.nil? }
-  
-  def conditions
-    [conditions_clauses.join(' AND '), *conditions_options]
-  end
-    
-  private
-    
-    def keyword_conditions
-      [&quot;products.name LIKE ?&quot;, &quot;%#{keywords}%&quot;] unless keywords.blank?
-    end
-    
-    def min_price_conditions
-      [&quot;products.master_price &gt;= ?&quot;, min_price] unless min_price.blank?
-    end
-    
-    def max_price_conditions
-      [&quot;products.master_price &lt;= ?&quot;, max_price] unless max_price.blank?
-    end
-    
-    def conditions_clauses
-      conditions_parts.map { |condition| condition.first }
-    end
-    
-    def conditions_options
-      conditions_parts.map { |condition| condition[1..-1] }.flatten
-    end
-    
-    def conditions_parts
-      private_methods(false).grep(/_conditions$/).map { |m| send(m) }.compact
-    end
-
 end</diff>
      <filename>app/models/search.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,8 @@
   &lt;/td&gt;
 &lt;% end %&gt;
 
+&lt;%= error_messages_for :search %&gt;
+
 &lt;% form_for @search do |f| %&gt;
   &lt;p&gt;
     &lt;%= t('ext.search.keywords') %&gt;:&lt;br/&gt;</diff>
      <filename>app/views/searches/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,8 @@
-&lt;div id=&quot;product-listing&quot;&gt;
-  &lt;%= t('ext.search.advanced_product_search') %&gt;
-  &lt;br/&gt;&lt;br/&gt;
-  &lt;%= render :partial =&gt; 'shared/advanced_search_sort_bar' %&gt;
-  &lt;br/&gt;
-  &lt;%= render :partial =&gt; &quot;shared/products.html.erb&quot;, :locals =&gt; {:products =&gt; @products, :taxon =&gt; @taxon } %&gt;
-&lt;/div&gt;
 &lt;% content_for :sidebar do %&gt;
-  &lt;td id=&quot;shop-by-col&quot; valign=&quot;top&quot;&gt;
-  	&lt;%= render :partial =&gt; &quot;shared/taxonomies&quot; %&gt;
-  &lt;/td&gt;
+	&lt;%= render :partial =&gt; &quot;shared/taxonomies&quot; %&gt;
 &lt;% end %&gt;
-&lt;%= render :partial =&gt; 'shared/advanced_search_paginate', :locals =&gt; {:collection =&gt; @products, :options =&gt; {}} unless @products.empty? %&gt;
+
+&lt;%= render :partial =&gt; &quot;shared/products.html.erb&quot;, :locals =&gt; {:products =&gt; @products, :taxon =&gt; @taxon } %&gt;
+
+&lt;%= render :partial =&gt; &quot;shared/advanced_search_sort_bar&quot; %&gt;
+&lt;%= page_links(maintain_search_params.merge(:prev =&gt; &quot;&amp;#171; #{t('previous')}&quot;, :next =&gt; &quot;#{t('next')} &amp;#187;&quot;)) if @search.page_count &gt; 1 %&gt;</diff>
      <filename>app/views/searches/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,3 @@
-&lt;%
-  # Build the custom parameters hash and don't clutter the url with empty params.
-  temp = {}
-  temp.merge!(:taxon =&gt; params[:taxon]) if !params[:taxon].nil? &amp;&amp; !params[:taxon].empty?
-  temp.merge!(:subtaxons =&gt; params[:subtaxons]) if params[:subtaxons] != &quot;0&quot;
-  temp.merge!(:min_price =&gt; params[:min_price]) if !params[:min_price].nil? &amp;&amp; !params[:min_price].empty?
-  temp.merge!(:max_price =&gt; params[:max_price]) if !params[:max_price].nil? &amp;&amp; !params[:max_price].empty?
-  temp.merge!(:keywords =&gt; params[:keywords]) if !params[:keywords].nil? &amp;&amp; !params[:keywords].empty?
-  temp.merge!(:p =&gt; params[:p]) if !params[:p].nil? &amp;&amp; !params[:p].empty?
-%&gt;
-
 &lt;table&gt;
 &lt;tr&gt;
 
@@ -20,12 +9,12 @@
 
 &lt;td&gt;
   &lt;%= link_to t('name'),
-    temp.merge(:sort =&gt; &quot;name_#{@sort_by.include?('ASC') ? 'desc' : 'asc'}&quot;)
+    maintain_search_params.merge(:sort =&gt; &quot;name_#{@sort_by_and_as[1].include?('ASC') ? 'desc' : 'asc'}&quot;)
   -%&gt;
 &lt;/td&gt;
 &lt;td&gt;
-  &lt;% if @sort_by.include?('name') -%&gt;
-    &lt;%= @sort_by.include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
+  &lt;% if @sort_by_and_as[0].include?('name') -%&gt;
+    &lt;%= @sort_by_and_as[1].include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
   &lt;% end -%&gt;
 &lt;/td&gt;
 
@@ -33,25 +22,25 @@
 
 &lt;td&gt;
   &lt;%= link_to t('price'),
-    temp.merge(:sort =&gt; &quot;price_#{@sort_by.include?('ASC') ? 'desc' : 'asc'}&quot;)
+    maintain_search_params.merge(:sort =&gt; &quot;price_#{@sort_by_and_as[1].include?('ASC') ? 'desc' : 'asc'}&quot;)
   -%&gt;
 &lt;/td&gt;
 &lt;td&gt;
-  &lt;% if @sort_by.include?('master_price') -%&gt;
-    &lt;%= @sort_by.include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
+  &lt;% if @sort_by_and_as[0].include?('master_price') -%&gt;
+    &lt;%= @sort_by_and_as[1].include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
   &lt;% end -%&gt;
 &lt;/td&gt;
 
 &lt;td&gt;&amp;nbsp;&lt;/td&gt;
 
 &lt;td class=&quot;sort_item&quot;&gt;
-  &lt;%= link_to t('date'),
-    temp.merge(:sort =&gt; &quot;date_#{@sort_by.include?('ASC') ? 'desc' : 'asc'}&quot;)
+  &lt;%= link_to t('ext.search.date'),
+    maintain_search_params.merge(:sort =&gt; &quot;date_#{@sort_by_and_as[1].include?('ASC') ? 'desc' : 'asc'}&quot;)
   -%&gt;
 &lt;/td&gt;
 &lt;td&gt;
-  &lt;% if @sort_by.include?('available_on') -%&gt;
-    &lt;%= @sort_by.include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
+  &lt;% if @sort_by_and_as[0].include?('available_on') -%&gt;
+    &lt;%= @sort_by_and_as[1].include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
   &lt;% end -%&gt;
 &lt;/td&gt;
 </diff>
      <filename>app/views/shared/_advanced_search_sort_bar.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -5,12 +5,10 @@ else
   search_path_local = products_path
 end -%&gt;
 
-&lt;br/&gt;
 &lt;div style=&quot;text-align: center;&quot;&gt;
 &lt;% form_tag search_path_local, :id =&gt; 'search_form', :method =&gt; 'get' do %&gt;
-  &lt;%= text_field_tag :search, params[:search] %&gt;
+  &lt;%= text_field_tag :keywords, params[:keywords] %&gt;
   &lt;%= submit_tag t('ext.search.search'), :name =&gt; nil %&gt;
 &lt;% end %&gt;
 &lt;%= link_to(t('ext.search.advanced'), new_search_path) %&gt;
-&lt;/div&gt;
-&lt;br/&gt;
\ No newline at end of file
+&lt;/div&gt;
\ No newline at end of file</diff>
      <filename>app/views/shared/_search_box.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -8,45 +8,39 @@
 &lt;td&gt;&amp;nbsp;&lt;/td&gt;
 
 &lt;td&gt;
-  &lt;%= link_to t('name'), {
-    :search =&gt; params[:search],
-    :sort =&gt; &quot;name_#{@sort_by.include?('ASC') ? 'desc' : 'asc'}&quot;,
-    :p =&gt; params[:p]
-  } -%&gt;
+  &lt;%= link_to t('name'),
+    maintain_search_params.merge(:sort =&gt; &quot;name_#{@sort_by_and_as[1].include?('ASC') ? 'desc' : 'asc'}&quot;)
+  -%&gt;
 &lt;/td&gt;
 &lt;td&gt;
-  &lt;% if @sort_by.include?('name') -%&gt;
-    &lt;%= @sort_by.include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
+  &lt;% if @sort_by_and_as[0].include?('name') -%&gt;
+    &lt;%= @sort_by_and_as[1].include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
   &lt;% end -%&gt;
 &lt;/td&gt;
 
 &lt;td&gt;&amp;nbsp;&lt;/td&gt;
 
 &lt;td&gt;
-  &lt;%= link_to t('price'), {
-    :search =&gt; params[:search],
-    :sort =&gt; &quot;price_#{@sort_by.include?('ASC') ? 'desc' : 'asc'}&quot;,
-    :p =&gt; params[:p]
-  } -%&gt;
+  &lt;%= link_to t('price'),
+    maintain_search_params.merge(:sort =&gt; &quot;price_#{@sort_by_and_as[1].include?('ASC') ? 'desc' : 'asc'}&quot;)
+  -%&gt;
 &lt;/td&gt;
 &lt;td&gt;
-  &lt;% if @sort_by.include?('master_price') -%&gt;
-    &lt;%= @sort_by.include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
+  &lt;% if @sort_by_and_as[0].include?('master_price') -%&gt;
+    &lt;%= @sort_by_and_as[1].include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
   &lt;% end -%&gt;
 &lt;/td&gt;
 
 &lt;td&gt;&amp;nbsp;&lt;/td&gt;
 
 &lt;td class=&quot;sort_item&quot;&gt;
-  &lt;%= link_to t('date'), {
-    :search =&gt; params[:search],
-    :sort =&gt; &quot;name_#{@sort_by.include?('ASC') ? 'desc' : 'asc'}&quot;,
-    :p =&gt; params[:p]
-  } -%&gt;
+  &lt;%= link_to t('ext.search.date'),
+    maintain_search_params.merge(:sort =&gt; &quot;date_#{@sort_by_and_as[1].include?('ASC') ? 'desc' : 'asc'}&quot;)
+  -%&gt;
 &lt;/td&gt;
 &lt;td&gt;
-  &lt;% if @sort_by.include?('available_on') -%&gt;
-    &lt;%= @sort_by.include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
+  &lt;% if @sort_by_and_as[0].include?('available_on') -%&gt;
+    &lt;%= @sort_by_and_as[1].include?('ASC') ? t('ext.search.asc') : t('ext.search.desc') %&gt;
   &lt;% end -%&gt;
 &lt;/td&gt;
 </diff>
      <filename>app/views/shared/_sort_bar.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -18,3 +18,4 @@ en-US:
       searching_by: Searching for '{{search_term}}'
       send: Send
       sort_by: Sort by
+      date: Date</diff>
      <filename>config/locales/en-US.yml</filename>
    </modified>
    <modified>
      <diff>@@ -18,4 +18,4 @@ pt-BR:
       searching_by: Procurando por '{{search_term}}'
       send: Enviar
       sort_by: Ordenar por
-
+      date: Data</diff>
      <filename>config/locales/pt-BR.yml</filename>
    </modified>
    <modified>
      <diff>@@ -8,29 +8,29 @@ class SearchExtension &lt; Spree::Extension
 
   def activate
     
-    # Add pagination support for the find_by_sql method inside paginating_find plugin.
-    PaginatingFind::ClassMethods.class_eval do
-      def paginating_sql_find(count_query, query, options)
-
-        # The current page defaults to 1 when not passed.
-        options[:current] ||= &quot;1&quot;
-
-        count_query = sanitize_sql(count_query)
-        query = sanitize_sql(query)
-   
-        # execute the count query - need to know how many records we're looking at   
-        count = count_by_sql(count_query)
-   
-        PagingEnumerator.new(options[:page_size], count, false, options[:current], 1) do |page|
-          # calculate the right offset values for current page and page_size
-            offset = (options[:current].to_i - 1) * options[:page_size]
-            limit = options[:page_size]
-   
-            # run the actual query - Note: do not include LIMIT statement in your query          
-          find_by_sql(query + &quot; LIMIT #{offset},#{limit}&quot;)
-        end
-      end
-    end
+#    # Add pagination support for the find_by_sql method inside paginating_find plugin.
+#    PaginatingFind::ClassMethods.class_eval do
+#      def paginating_sql_find(count_query, query, options)
+#
+#        # The current page defaults to 1 when not passed.
+#        options[:current] ||= &quot;1&quot;
+#
+#        count_query = sanitize_sql(count_query)
+#        query = sanitize_sql(query)
+#
+#        # execute the count query - need to know how many records we're looking at
+#        count = count_by_sql(count_query)
+#
+#        PagingEnumerator.new(options[:page_size], count, false, options[:current], 1) do |page|
+#          # calculate the right offset values for current page and page_size
+#            offset = (options[:current].to_i - 1) * options[:page_size]
+#            limit = options[:page_size]
+#
+#            # run the actual query - Note: do not include LIMIT statement in your query
+#          find_by_sql(query + &quot; LIMIT #{offset},#{limit}&quot;)
+#        end
+#      end
+#    end
   end
   
   def self.require_gems(config)</diff>
      <filename>search_extension.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0bc99d24b78f20546119300d3b22c188cce614a5</id>
    </parent>
  </parents>
  <author>
    <name>Edmundo Valle Neto</name>
    <email>edmundo.vn@gmail.com</email>
  </author>
  <url>http://github.com/edmundo/spree-search/commit/07186759b799148f40992379fe5c12f888a3491f</url>
  <id>07186759b799148f40992379fe5c12f888a3491f</id>
  <committed-date>2009-06-01T11:38:29-07:00</committed-date>
  <authored-date>2009-06-01T11:38:29-07:00</authored-date>
  <message>Updated to work with searchlogic.</message>
  <tree>8c172abeab3cf0e2247e80d49584740f0a05b56b</tree>
  <committer>
    <name>Edmundo Valle Neto</name>
    <email>edmundo.vn@gmail.com</email>
  </committer>
</commit>
