getProduct() error

Hi,
Getting ediror error + code is not executed.
The console.log is not printed.
Please advise:)
Dafna

Your code looks fine (the fact that “getProduct” is red will be resolved soon, but it’s not related to your issue)

Here are some ways you can debug this:

  1. Verify that “productPage” is the correct id of your product page
  2. Simplify your code, just do $w(“#productPage”).getProduct().then(console.log).catch(console.log) and see if you get anything printed out
  3. Check the console for errors

If you are unable to resolve this, please send me your site address so I can have a look

Thanks,
Oded

Hi,
it’s not printing the log.
site: brinadavid
url: https://www.brinadavid.co.il/Stores/Products/36ccb2bc-f1cf-a720-b573-8b3d0f14f7f1
This product id is for a product that has the relevant setup
The code is under the product dynamic page
Thanks a lot!
Dafna:)

It doesn’t work because $w(" #productPage ") is not a product page.
The purpose of this API is to allow getting the product from the “native” product page, the one that is under “Product Page” page

Thanks,
Oded

Not sure I understand

Let me try and explain.
When you install stores, you get 4 pages added to your site:

  1. Shop (פירות)
  2. Product Page (under פירות)
  3. Thank you page (under פירות)
  4. Cart (under פירות)

The API you are using, allows you to read the product being presented in the “Product Page”. The most common use case is to get the id of the product and then use it in another table. This allows you to extend the native product page with ratings, related items and other use cases.

I don’t think this is what you need, since you creating a dynamic product page and not using the native one

ok. got it form data query:)
Thanks

Hi:)
Another post regarding Wix Stores with code:

Thanks a lot,
Dafna

Hi there, I am getting the same error and I am using a native product page. Please can you advise?

The site is
www.ajiaj.com

Hi Alan,

Unfortunately this looks like an issue in our side, I’m looking into this and will let you know

Thanks,
Oded

Hi Alan,

This issue has been resolved :slight_smile: I verified and it your website seems to be working fine now.

Just one comment though - I see that have used “getProduct” in order to implement related items. Just keep in mind that clicking the related items link refreshes the item displayed on the page but “onReady” isn’t called again so getProduct isn’t called again. This is something that we are looking into.

In the meantime, if this important to you, you can listen to the click event on the repeater item and then get the data from the dataset. This code demonstrates the general idea:

$w.onReady( function () {
$w(“#productPage1”).getProduct().then(x => console.log(x.slug)). catch (console.log)

// #image1 is inside a repeater
$w(“#image1”).onClick((event, $w) => {
console.log($w(“#dataset1”).getCurrentItem().slug);
})
});

Please let me know if your have any further questions!

Thanks,
Oded

Thank you Oded for your reply, I made a referrer page with the following code

import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;

$w.onReady( function () {
let referrer = wixWindow.referrer;
let url = “” + referrer;
wixLocation.to(url);
} );

Do you think it is possible to redirect to the referrer page on refresh? Maybe by adding a query to the link?

Hi Alan, this is off topic and not related to “getProduct”, would you mind creating a new forum post?

Thanks,
Oded

Hi Oded, it appears that the issue with the getProduct command is reappearing. Please can you assist?
Thank you very much for your time.

https://www.ajiaj.com/product-page/eve-lom-卸妝潔面啫喱

Hi Alan,

This should be fixed now

Regardless,
I noticed that your web page issues three requests to “getProduct” when looking at the network tab - the more requests you have, the slower you website will load.
I would advice that you inspect your code and fix.

Thanks,
Oded

Thanks for the fix and advice, Oded. I have just started to learn how to code like two, three weeks ago. I will try to fix it. :slight_smile:

Hi Oded,

I am running into this issue:

My wix code has recently stopped loading products and showing a ‘product not found error’ in the console, but only for older products in my site. For newer products added in the last week, the code on my product pages works fine.

Is this something you can help with?

For more info, here is a URL where the product cannot be loaded with wix code:

https://www.littlebeesplants.co.uk/product-page/allium-ambassador

And here is a product page where the same code is able to load the product and print the ID and Slug.

https://www.littlebeesplants.co.uk/product-page/dahlia-david-howard

In this case the only difference is that the ‘dahlia david howard’ product was added today, whereas the other product was added months ago.

Hi Christian,

There was an issue specifically with your store (on our end) I fixed it and things seems to be working now.

Thanks,
Oded

Thank you very much for your quick response and resolution! Christian