Hi, i’m trying to set a filter for available desce...
# support
w
Hi, i’m trying to set a filter for available descendant of current taxon it works with taxon (category), but if i start from a taxon that has no descendants (brand) i get something like this SQL :
AND “spree_products_taxons”.“taxon_id” = $2 AND “spree_products_taxons”.“taxon_id” = 4
there is a way to manage this? maybe using a subquery with arel? Thanks
n
w
maybe i did not understand what do you mean, or i did not well explain my problem. on a taxon (category taxonomy) with descendants page the scope is something like:
AND "spree_products_taxons"."taxon_id" IN (2, 5)
if i want narrow search on a sub category, on solidus filter i use arel_scope
arel[:taxon_id].eq(5)]
and the added search scope is
Spree::Product.joins(:classifications).where(arel_scope)
ending with correct sql
AND "spree_products_taxons"."taxon_id" IN (2, 5) AND "spree_products_taxons"."taxon_id" = 5
on a taxon (brand taxonomy) i cant use a scope to narrow search because the data i search is outside of current taxon scope. Until now my only idea is unscope
taxon_id
and recreate the query inside filter scope.
seems that filtering by different taxonomy at the same time, is not supported out of the box. i manage this using nested subquery inside filters and monkey patching Spree:CoreSearch:Base#add_search_scopes to group taxon scope under only one scope_name with union of scope_attributes.