There are two ways to filter a dataset: using code (as in this example) or via the Dataset Settings panel of the dataset.
async function initReviews() {
await $w('#Reviews').setFilter(wixData.filter().eq('productId', product._id));
showReviews();
loadStatistics();
}
Line 2: Chain an eq function to setFilter to filter out all items in the Reviews dataset where the product ID doesn’t match the ID of the currently displayed product.
If you want to use this exact scenario and code in your site, you may need to modify these items to match the ones on your site:
Also, just to make sure that you do have the required imports and the let at the top of your code as mentioned in the tutorial too.
Plus, try changing your code back to how it was written in the tutorial as $w.onReady(async function () { instead of writing it like you have as $w.onReady( async () => { - just covering all bases here as it should not matter.
import wixData from 'wix-data';
import wixWindow from 'wix-window';
let product;
$w.onReady(async function () {
product = await $w('#productPage1').getProduct();
initReviews();
});
Lines 1-2: Import the modules we need to work with Wix Data and Wix Window libraries.
Line 5: Define the global product variable.
Line 7: When the page loads, do the following:
Line 8: Using the getProduct function on the current product page, set the product variable to the currently displayed product.
Line 9: Run the initReviews function to load the current product’s ratings and reviews.
Thanks for the quick reply. No - the review and rating does not follow the mentioned tutorial. My program is breaking in the first line of onReady -
product = await $w(‘#productPage1’).getProduct();
which was working as it is few days back.
I am getting the same error in my code too. I am new to corvid and wix . I was trying few things for my new website. The get.product function was working perfectly on Feb 18 2020. But not working today. No change was made . I tried restoring site to the older version and tried coding again . I get the same error. Please advise
Here is the code
$w(‘#productPage1’).getProduct()
.then( (product) => {
ProductVariant(product._id,VariantDays())
.then((variants)=>{
This is now a BLOCKER for me. Not sure how to reach out to the WIX guys, to register a valid bug. Not able to update my site (premium service) with new content unless this is resolved.
@juny929 thank you, I have just just checked my published version and all the shop pages and sliders are missing, is this something disabled on your end?