buildMustQuery method
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
mustclause.
Implementation
List<QueryClause> buildMustQuery(int categoryId, String? vendorId) {
return <QueryClause>[
QueryMatch('catalog_category_id', categoryId.toString()),
if (vendorId != null) QueryMatch('vendor_id', vendorId),
];
}