Set up variant tags as searchable

This commit is contained in:
Gaetan Craig-Riou
2025-04-16 14:56:01 +10:00
parent 3ec14607a6
commit 3bb0176887
2 changed files with 19 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ module Spree
acts_as_taggable
searchable_attributes :sku, :display_as, :display_name, :primary_taxon_id, :supplier_id
searchable_associations :product, :default_price, :primary_taxon, :supplier
searchable_associations :product, :default_price, :primary_taxon, :supplier, :tags
searchable_scopes :active, :deleted
NAME_FIELDS = ["display_name", "display_as", "weight", "unit_value", "unit_description"].freeze

View File

@@ -1 +1,19 @@
# frozen_string_literal: true
ActsAsTaggableOn.force_lowercase = true
# Monkey patch suggested as workaround to the allowlisted issue
# This may be removed when an official fix is included in Ransack
module ActsAsTaggableOn
class Tag
class << self
def ransackable_associations(_auth_object = nil)
["taggings"]
end
def ransackable_attributes(_auth_object = nil)
["name"]
end
end
end
end