Thank you. I just made a simple page for product searching with product name textbox and product collections dropdownlist. When i click Search button i want it filter name and collection name to display products.
Here’s my code:
export function searchButton_click() {
search();
}
export function searchBar_keyPress(event, $w) {
if (event.code === 13){
search();
}
}
function search() {
let collectionName=$w(“#collectionDropdown”).value;
wixData.query(‘Stores/Products’)
.contains(‘name’, $w(“#searchBar”).value)
.hasSome(‘collections’, collectionName)
.find()
.then(res => {
$w(“#repeater1”).data=res.items;
})
. catch ( (error) => {
let errorMsg = error.message;
let code = error.code;
console.log(“ERROR:”+code+" | "+errorMsg);
} );
}
It doesn’t need toString() for dropdown value. I call search function from Search button click event. Is it ok?
Without collection dropdownlist, my page is working normally. But with it, searching doesn’t work.
I don’t know this code: .hasSome(‘collections’, collectionName) is right or wrong. Collection field in Wix Product is a reference field and has type is array. I don’t know how to use it.
Here’s when i clicked Search button, there’s nothing display, no any log:
Please help me to make it work.
