Hi, we're using TS Cloud on a WooCommerce site and...
# community-help
i
Hi, we're using TS Cloud on a WooCommerce site and I'd like to apply a custom sort order to specific categories. I have created an Override applying Sort Documents as follows:
_eval([ (product_brands_attribute_filter:Climadoor):3, (product_brands_attribute_filter:LPD):2, (product_brands_attribute_filter:DEANTA):1 ]):desc, price:asc
This works fine in that the sort order has all products from the first brand in ascending price order, then same for the second brand etc. However, it is applied universally to all category pages and search results. I just want it applied to a specific category (or possibly several). I have tried using Curate by Filter set to match a category (e.g. category:Architrave), but that has no effect. To note, the way the website works is that category page listings are driven by TS results, i.e. they are "search results" but without a user actually searching. This is done with a third-party plugin and I don't know how it queries TS to generate the category page listings, but obviously category is an attribute in the product data. Can someone please help me set an override that will only apply when a particular category is viewed on the site?
a
@Ian Lockwood You can try adding tags to the curation rules: https://typesense.org/docs/29.0/api/curation.html#add-tags-to-rules Or when using filter_by: https://typesense.org/docs/29.0/api/curation.html#dynamic-filtering Additionaly, you can try checking the network tab on developer tools and inspect the request being sent to typesense, to get more information
i
Thanks @Alan Martini, sorry it's taken so long to reply. I've looked at the options you suggest, but because it's a plugin for WordPress, I can't see a way to apply tags to the initial request. For a page like this: https://www.doorsonlineuk.co.uk/internal-doors/ the network tab output looks like this:
Copy code
searches: [{query_by: "post_title,post_content",…}, {query_by: "post_title,post_content",…}]
 0: {query_by: "post_title,post_content",…}
  collection: "product"
  facet_by: "category,pa_colour_attribute_filter,pa_construction_attribute_filter,pa_door-opening-pattern_attribute_filter,pa_door-pattern_attribute_filter,pa_finish_attribute_filter,pa_french-pair-width_attribute_filter,pa_glazing_attribute_filter,pa_material_attribute_filter,pa_pack-type_attribute_filter,pa_part-q-compliant_attribute_filter,pa_size_attribute_filter,prices,product_brands_attribute_filter"
  filter_by: "category:=[`Internal Doors`]"
  highlight_full_fields: "post_title,post_content"
  max_facet_values: 100
  page: 1
  per_page: 18
  q: "*"
  query_by: "post_title,post_content"
  sort_by: "_eval([ (product_brands_attribute_filter:Climadoor):3 ]):desc"
 1: {query_by: "post_title,post_content",…}
  collection: "product"
  facet_by: "category"
  highlight_full_fields: "post_title,post_content"
  max_facet_values: 100
  page: 1
  q: "*"
  query_by: "post_title,post_content"
  sort_by: "_eval([ (product_brands_attribute_filter:Climadoor):3 ]):desc"
I was hoping I could set a rule in the Override itself to match the filter_by field in the query (e.g. a rule whereby if filter_by: "category:=[
Internal Doors
]" then pin a particular product to position 1). I can't get that to work using the TS Cloud Override option though, am I doing something wrong or is it not possible just using an Override with the query as seen above?
To add, I have tried setting Curate by Filter in the Override to: category:=[
Walnut Internal Doors
] The rule I set works (ordering by brand, then price ascending), but it applies to all categories on the site. How can I get the Curate by Filter to match the filter_by in the original query from the site?