Skip to content

Feat: Nested collection groups filters on products#103

Merged
repl6669 merged 3 commits into
1.0from
feat/nested-collection-groups-filters
Apr 9, 2026
Merged

Feat: Nested collection groups filters on products#103
repl6669 merged 3 commits into
1.0from
feat/nested-collection-groups-filters

Conversation

@repl6669

@repl6669 repl6669 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new collection_groups filter to the Products JSON:API schema, enabling filtering products by collections across multiple collection groups simultaneously.

This solves the problem of needing AND logic between collection groups (e.g. "products in category X and season Y") while maintaining OR logic within each group's collection IDs.

Usage

Filter key

filter[collection_groups][{group_handle}][id]={collection_ids}
  • {group_handle} — the handle of a CollectionGroup (e.g. product_type, edition, target)
  • {collection_ids} — comma-separated collection IDs

Example

GET /api/v1/products?filter[collection_groups][product_type][id]=4&filter[collection_groups][edition][id]=47,46,45&filter[collection_groups][target][id]=20,21

This returns products that:

  • Belong to collection 4 in the product_type group, AND
  • Belong to collection 47, 46, or 45 in the edition group, AND
  • Belong to collection 20 or 21 in the target group

Filtering logic

Scope Logic
Between groups AND — product must match all specified groups
Within a group's IDs OR — product must belong to at least one of the listed collections

Combining with other filters

The new filter works alongside all existing product filters:

GET /api/v1/products?include=thumbnail,lowest_price,collections&filter[collection_groups][category][id]=4&filter[in_stock]=true&filter[brand][id]=1,2

Changes

  • New: CollectionGroupFilter — custom JSON:API filter class (packages/api/src/Domain/Products/JsonApi/Filters/CollectionGroupFilter.php)
  • Modified: ProductSchema — registered collection_groups filter (packages/api/src/Domain/Products/JsonApi/V1/ProductSchema.php)
  • New: CollectionGroupFilterTest — 4 test cases covering single group, OR within group, AND across groups, and no-filter baseline (tests/api/Feature/Domain/Products/JsonApi/V1/CollectionGroupFilterTest.php)

@repl6669 repl6669 changed the title Feat: Nested collection groups filters Feat: Nested collection groups filters on products Apr 9, 2026
@repl6669 repl6669 merged commit bd2f668 into 1.0 Apr 9, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant