Filter Dataset 'title' field to 'Name' feild of current Product Selection

I currently have a database that contains information relating to each product in my store.
I’ve placed this dataset into the store/product page, and need to filter the dataset to match the current product being shown.

If I were on a dynamic page I would have access to the ‘Products Item’ dataset that is linked to the dynamic(title) page. But I dont seem to have that functionality set into the store’s product page.

Any ideas or code for filtering a dataset’s ‘title’ field to the ‘name’ field of the Stores/Products Database once I have clicked a specific product?

Hi bronsin.
here i have a guide on how to filter a dataset.
https://www.wix.com/corvid/forum/main/comment/5eb3c9bf0ef3270017786f85
If you need to filter by code you should check the corvid api page.
here’s a link to the dataset api
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html

kristof.

Hi Kristof, thanks for the info but not quite what I’m looking for.
I have a repeater on my store product page that I have connected to a secondary database. This Database’s titles match the Names of the products in my store. I want to filter the Database to match or show the corresponding Dataset Title and Store Product Name. Any ideas?

This is the code I stumbled upon to solve this problem:

//////////////////
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();
});

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

/////////////////
#ProductPage1 = selected Store product page (seems typical of the standard product page)
#dataset2 = Dataset I want to filter by the ProductId of the current page
‘refToStore’ =the ID of the field in dataset2 referencing the Stores/Product

Seems to work well!!!

Hi ! I need help, I have tried everywhere.

(I am not working with WixStores product reviews.)
I have a website that is a directory that displays a list of businesses. I want users to be able to leave ratings/reviews for each specific business. I am trying to either use the dataset filter or find a code that will:
* filter the rating/review on that dynamic page based on the current business page the user left the review for. Each dynamic page (business page) should have it’s own unique dynamic reviews. PLEASE HELP :frowning:

@aalexandriaproductio Hi, I’m rather new to wix and am no expert. but, did you try creating a reference in the rating/review database to the business database? and then filtering the dynamic dataset by this reference? I know wix has a few tutorials on creating reviews, have you checked the link below? This tutorial helped me figure out the code I put above.

@bronsinablon Hi , thank you! Yes, everyone keeps pointing me to this page but question:

  1. should this code be on the actual dynamic page or on the lightbox?

  2. Re: the code below, since i am not reviewing product, what will i change " #productPage1 ", “productId” and “product._id” to?

  3. on the product page, it looks like the “productPage1” is a combined/fixed module. What would that correlate to on my site?
    (see attached photo)

I haven’t used datasets on lightboxes but my understanding is that lightboxes are pretty much like pages themselves. If you are trying to display data on a lightbox I would guess you would need a dataset on the lightbox with the code input there as well. its worth trying to troubleshoot.

for your other questions:
click on your dynamic page’s background and the page ID should come up ‘it will be’#whateveryourpageisnamed’. On my new dynamic pages it is usually something like ‘#page1’ this should replace #productPage1.
‘productID’ is the the Feild Key in your dataset that references the
main database. in mine I named it ‘refToStore’ , for example. I think 'product._id, in your case, can stay the same. But check your main database’s feild key to make sure it matches up to what you are trying to match together.

I’ve grabbed a screen shot of what my page actually uses.
This was a super annoying thing to figure out, I wish Wix made this a little easier. I hope this helps!!

@aalexandriaproductio One more thought. If you are showing a business on the dynamic (title) page I think it will automatically set the dynamic dataset of the page to the ID of the current business. then you can just use the filter feature in the second dataset to filter by title or other field. this way you don’t need to add code to the page.

i appreciate your help! ugh… for whatever reason, it is giving me an error message

Hello Kristof! Not sure if you can help me with my question below too? Bronsin has been pretty helpful, but something is off with my code.

Hi @aalexandriaproductio
i’m sorry i just readed your question. i was away for the weekend.
What you should do is.

  1. make a database “businesses” and “businessReviews”
  2. make a repeater on your dynamic page (All)
  3. link it to the business dynamic dataset.
  4. On the page (Title) add a repeater
  5. add the businessReviews dataset there.
  6. link the repeater to the businessReviews.
  7. add a filter to the "businessReviews " dataset so the “businessReviews” filters on the same name as the dynamic “business” dataset. fields to compare depend on the name of business.

so what this does is when you click on the business it will go to the dynamic page (Title) , the businessReview dataset will filter only on what has the same business name as the business dynamic dataset.
now evrything connected in the repeater will be reviews of the current clicked business.

now add another “businessReview” dataset. make this one read&write
above the repeater add the needed input fields (rating,title,comment)
link those to the dataset.
add a submit button to save the new dataset so the data is saved to the database.
also make sure to save the current business name so the review gets on the current page afterwards

kristof.

@volkaertskristof Hello Kristof! Thank you so much! I have done this, but it does not seem to be working.

I think where i am getting hung up on is the last part where you say "
also make sure to save the current business name so the review gets on the current page afterwards "

in my screenshots, you will see that i have made a business and Reviews datasets. I also have an (All) page along with the business list repeater connected, and a (title) page page, which has the business list and reviews datasets on the page, as well as a reviews repeater.

@aalexandriaproductio
Atm i have no time to read evrything an. answer it,
Tomorrow i will durning midday (in 16h from now)

Kristof.

If you want i also can take a look on your website then if you make me a contributor(you can always copy your website and make me a contributor there if you want to be sure nothing happends to your website)

My email to make contributor is kristof.print3d@gmail.com
Also send where i need to look if you have multiple dynamic pages.

Kristof.

@volkaertskristof thank you Kristof. I will talk to you in 16hours or so and we can discuss then. Also I am not sure if you take phone calls or phone consultations but Id love to quickly chat if you would rather do that.

@aalexandriaproductio
I’m not realy a person that likes to call :sweat_smile: and i’m from belgium, calls aint cheap also when i have access to your website or copy i will tzll you excactly what i have done with screenshots from your editor so you can follow it easy :slight_smile:

@volkaertskristof haha! ok when i get home, i will connect you with my site

@volkaertskristof Thank you so much Kristof! I have shared access of my site with you. We will be looking only at the " BizSearchResults (All)" and “BizSearchResults (BizName)” pages

Datasets: Reviews result = Reviews repeater
Reviews = Submit a Review lightbox

Ok so if you go to “BizSearchResults (BizName)” title page, the Reviews repeater is on the very bottom, accompanied with it’s dataset. Please look at the “Reviews result” dataset and the “Submit A Review” dataset & “Reviews” lightbox and please let me know what i ma doing wrong because when I write 1 review for 1 business, it shows up on every business’ page. I want one review to be on each respective busniess page. Please help!

Let me know if you have any trouble accessing my site.
My email: a.alexandriaproductions@gmail.com

@aalexandriaproductio
Oke i’m here but i will send an email so the post is not bumped the while time