Filter dataset by product collection- create product gallery on dynamic page

I have created a dynamic page which displays information from a data set. I am wanting to have a product gallery on each dynamic page displaying a specific collection which corresponds to the information from the data set that is displayed on that particular page. I am using wix store and have inserted the stores/product dataset onto the page and am wanting to filter this to display the products from a specific collection in a repeater. However, I found that it is not possible to filter by collection just through the dataset filter options as it is a hidden field. I have found the following 2 codes that it is said they are suppose to help do this however I am unsure how to use them and connect them to the relevant collection to display on each page.
Code 1:
import wixData from ‘wix-data’; $w(‘#myDataset’).setFilter(wixData.filter() .hasSome(‘collections.id’, [‘collectionID’, …]) )

Code 2:
wixData.filter(‘Stores/Collections’).find()
.then((result) => {
return result.items[1];
})
.then(collection => {
return wixData.filter(‘Stores/Products’)
.hasSome(‘collections.id’, [collection._id]) //<<<<<<<<<
.find()
})
.then((result) => {
let products = result.items;
debugger;
});

1 Like