Query filter product by Collection(now called category)

I am very new so hopefully, this is easy and I am just missing it. It’s really hard to search for answers because the terminology for a Product Collection(now called categories) returns a lot of results about the wrong type of collections

How can I query and get results for Products that belong to a specific Collection(now called product category)?

Example: Query and return all products in the Surfboard Collection/Category.

The end result I am going for is based on user action displaying a specific product category in a repeater but I can’t get any results in my queries.

It would be more informative if you would present an excerpt of your database, or a example of it.

  1. What is the ID of your DATABASE ?
  2. Are you using a DATASET ?
  3. Or do you want to use → Wix-Data?
  4. What is the ID of the DB-Field, you want to filter in?
  5. If you want just a basic filter…
import wixData from 'wix-data'

let DATABASE = "your DATABASE-ID here";
$w.onready(()=>{
	wixData.query(DATABASE)
	.find()
	.then((res)=>{
		let items = res.items;		
		if(items.length>0) {return items}
		else {return {}}		
	}).catch((err)=>{console.log(err);});
});

Thank you for the reply it help me rethink what I was doing and I have it working now. I was trying to use the collection name as a string and not the ID of the collection itself.

1 Like