vtex / faststore

Digital commerce toolkit for frontend developers
https://faststore.dev
MIT License
189 stars 60 forks source link

Feat/expand store facet range detection #2294

Closed brunorodmoreira closed 5 months ago

brunorodmoreira commented 5 months ago

What's the purpose of this pull request?

VTEX's Intelligent Search has a feature that allows convert any parameter to numeric, thus unlocking the ability to filter using ranges, just like price does. Although, the API's facet type field doesn't change the value, keeping it as "TEXT". The current StoreFacet resolver implementation only considers "RangeType" for values different from "TEXT", which restricts it to prices, that have the type "PRICERANGE" (reference: https://developers.vtex.com/docs/api-reference/intelligent-search-api#get-/facets/-facets-:~:text=Allowed%3A%20TEXT%E2%94%83PRICERANGE). This PR aims to unlock the ability to have another range filters in ProductGallery, then we can implement filters by dimension for example.

Screenshots: image image

image

How it works?

I expanded the logic to set a facet as a range and change the filter component behavior to make it more generic, because currently it's specialized for prices. It keeps coupled to price component internally, but I think it's possible to evolve it after.

How to test it?

Set an attribute as numeric using Intelligent Search Settings and access a category that contains the facet.

Starters Deploy Preview

References

vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
faststore-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 8:06pm
codesandbox-ci[bot] commented 5 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.