Cannot link the photo to each product

Hello guys. I have questions on adding extra product detail gallery (Banner + Detail Shoot) relating to each products.
Hope that I can get solutions here.

I use Wix preset product page but I cannot add field in the read-only database.
So I make another dataset called Product list (#dataset2) with Banner + Detail Shoot gallery.

ID as the common field of products database and Product list database.

Take the product (1b2ca124-cd57-56cd-482d-5c9d9ae6923c) as an example.

But I find that I have to generate the specific product id on each page, so I can connect the related fields( Banner & detail shoot) in dataset2.

I believe that I need Corvid to generate

  1. Get the product id

  2. filter the data in dataset2 regarding the product id

  3. link the detail shoot field in dataset 2 to the #gallery1 & #gallery2

May anyone help me please😥 Thanks a lot!


Update:
I discovered a code to fix this already, hope to help any newbies like me

import wixData from ‘wix-data’ ;
import wixWindow from ‘wix-window’ ;
import wixStores from ‘wix-stores’ ;

let product;

$w.onReady( async function () {
product = await $w( ‘#productPage1’ ).getProduct(); filterDataset();
$w( ‘#dataset2’ ).setFilter(
wixData.filter()
.eq( ‘id’ , product)); filterDataset();
});

async function filterDataset() {
await $w( ‘#dataset2’ ).setFilter(wixData.filter().eq( ‘id’ , product._id));
}

This generate the related photo to each product page~
Hope it can help

Problem appear again after I publish the website.

With the above coding, the correct related photos did link to each product.

But in “view live site” mode, the galleries are unable to link as editor mode shown.

I thought it may be related to these error, may somebody help on these?

Thanks a lot xoxo