Skip to Content
FeaturesCollections

Collections

Collections group products for navigation and merchandising. Products are derived dynamically from filter rules.

Creating Collections

const collection = await collectionService.create({ name: "Summer Sale", slug: "summer-sale", description: "Best deals for summer" });

Filter Rules

Collections use filter rules stored as rows in collection_filters. Products matching the filters are included automatically.

// Add a facet filter — include products with specific facet values // (value is an array of facet value ids; matches product- and variant-level facets) await collectionService.addFilter(collectionId, { field: "facet", operator: "in", value: [12, 13] }); // Add a price filter — products under 50€ await collectionService.addFilter(collectionId, { field: "price", operator: "lte", value: 5000 }); // Remove a filter await collectionService.removeFilter(filterId);

Filter Fields

FieldDescription
facetProducts with specific facet values
pricePrice range
stockStock level
visibilityProduct visibility
productSpecific products (manual)
variantSpecific variants

Filter Operators

eq, in, gte, lte, gt, contains

Querying Collections

// Get collection by slug const collection = await collectionService.getBySlug("summer-sale"); // Get products for a collection with pagination const { items, pagination } = await collectionService.getProductsForCollection( collection.id, { limit: 20, offset: 0 } ); // Count matching products without hydrating them const count = await collectionService.getProductCount(collection.id);

Returned products are hydrated through productService.loadProductsRelations, a batched loader with a fixed query count.

Collection description HTML (and its translations) is sanitized on save with src/lib/server/sanitize.ts.

Last updated on