Question:
Hi. I’m wondering is the is a way to filter the products fetch using the queryProduct in wix sdk. I’m trying to build an e-commerce website using wix ecom headless solution. I want to to be able to filter the products to return only those with matching criteria e.g in a case of a cloth store to return cloths of specific size or color. I’m using next js framework for development.
Product:
Wix sdk, ecom and store headless solution
What have you already tried:
Right now I’m only able to filter the products by price , category and by price range using the existing properties of the queryProduct builder such as eq(), startwith() and le(). I couldn’t find a way to filter the product based on their variations (e.g size and color)
Additional information:
-I’m using Next 15 js with wix ecom headless solution
-The fetching is done on a server component and parameters access from url using Next js searchParams api
Currently, the Wix Ecom Headless solution does not provide direct filtering of products based on variant-specific attributes (e.g., size, color) using queryProducts. The queryProducts builder primarily filters products based on top-level product fields such as price, categories, or title. Unfortunately, product variants are nested properties and aren’t directly queryable using the existing methods like eq(), startsWith(), or le(). If you need further help with this will be happy to do so.
Ok I see. Thank you for your reply! For now what I did is created a function that filters out the products return by the productQuery() using the choices property of the productOption of a product on the server component where the product is been fetch. and it seems to do the work for now. That seems to do the trick but I feel like there surely exist a more optimize and efficient way to do this. Thanks for your asssistance