I am trying to query products based on price in the same collection as the current collection of the product. Unfortunately i’m not sure how to filter into the collection of the product.
async function relatedProductsByPrice(product) {
let productId = product._id;
let relatedByPrice = await wixData.query( ‘Stores/Products’ )
.contains( “collections” , product.collections)
.between( ‘price’ , product.price * 0.7 , product.price * 1.3 )
.ne( ‘_id’ , productId)
.find();
return relatedByPrice.items;
}
The collection needs to be dynamic and based on the product that the customer is looking at. Please let me know what I am doing wrong.