buildMustQuery method

List<QueryClause> buildMustQuery(
  1. int categoryId,
  2. String? vendorId
)

Builds the required "must" query clauses for a product search.

This method constructs the must clause of the query which includes filtering by the provided categoryId and optionally the vendorId.

  • Parameters:

    • categoryId: The ID of the category to filter products by.
    • vendorId: Optional vendor ID to filter products by vendor.
  • Returns: A list of query clauses to be used in the must clause.

Implementation

List<QueryClause> buildMustQuery(int categoryId, String? vendorId) {
  return <QueryClause>[
    QueryMatch('catalog_category_id', categoryId.toString()),
    if (vendorId != null) QueryMatch('vendor_id', vendorId),
  ];
}