Sha256: 7b707b918e0127c9bfd040ddf4d30482833fb4938da91bf7d0d1fcaa0e3c07a3

Contents?: true

Size: 612 Bytes

Versions: 1

Compression:

Stored size: 612 Bytes

Contents

module SpreeMobility::CoreExt::Spree
  module VariantDecorator
    module ClassMethods
      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 LOWER(:query)) OR (LOWER(#{::Spree::Variant.table_name}.sku) LIKE LOWER(:query))", query: "%#{query}%").distinct
      end
      
      def search_by_product_name_or_sku(query)
        product_name_or_sku_cont(query)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_mobility-1.0.0 lib/spree_mobility/core_ext/spree/variant_decorator.rb