Skip to content

Instantly share code, notes, and snippets.

@francesco-carrella
francesco-carrella / custom_searcher.rb
Last active August 29, 2015 14:26 — forked from killthekitten/custom_searcher.rb
Dumb way to filter products by multiple properties in Spree.
class CustomSearch < Spree::Core::Search::Base
protected
def add_search_scopes(base_scope)
statement = nil
search.each do |property_name, property_values|
property = Spree::Property.find_by_name(property_name.gsub("_any", ""))
next unless property
substatement = product_property[:property_id].eq(property.id).and(product_property[:value].eq(property_values.first))