Module: SpreeMobility::CoreExt::Spree::VariantDecorator::ClassMethods

Defined in:
lib/spree_mobility/core_ext/spree/variant_decorator.rb

Instance Method Summary collapse

Instance Method Details

#product_name_or_sku_cont(query) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/spree_mobility/core_ext/spree/variant_decorator.rb', line 4

def product_name_or_sku_cont(query)
  helper =
    SpreeMobility::TranslationQuery.new(
      ::Spree::Product.mobility_backend_class(:name))

  helper.add_joins(self.joins(:product)).
  where(
    "(LOWER(#{helper.col_name(:name)}) LIKE :query) OR (LOWER(#{::Spree::Variant.table_name}.sku) LIKE :query)", query: "%#{query&.downcase}%").distinct
end

#search_by_product_name_or_sku(query) ⇒ Object



14
15
16
# File 'lib/spree_mobility/core_ext/spree/variant_decorator.rb', line 14

def search_by_product_name_or_sku(query)
  product_name_or_sku_cont(query)
end