I have a basic Wix store. It uses the Products and Collections store tables. I am trying to figure out how to filter the products shown in the Wix Default Product Gallery by code, setting up the collection that I want to show with its ID string.
At this moment I am only able to accomplish this by creating as many pages as collections and set the collection manually for every page. I need to use the default wix shop, and set a dynamic dataset to include only products that belong to a collection.
An ideal solution would be having a dynamic page of the Stores/Collections database and only show products from that collection, but that does not work either.
Thank you in advance!
#store #collection #wixcode #corvid #dynamic
@gasparmelsion I just answered a similar question in facebook: Totally Codable Community - Web Design, Wix, Velo, No Code and more . . . | Facebook.
The answer is addressed in Wix Stores data collection docs:
In the first link you will see the method you need to use to do what you need. Basically you need to use .hasSome() to filter on the collection id. Then you need to make sure you are using the correct syntax for collection ids. Specifically .hasSome(‘collections.id’, [<collection._id value>]).
Here is the test I ran which worked. I used wixData with query(). For data collections simply replace query with filter.
wixData.query('Stores/Collections').find()
.then((result) => {
return result.items[1];
})
.then(collection => {
return wixData.query('Stores/Products')
.hasSome('collections.id', [collection._id]) //<<<<<<<<<
.find()
})
.then((result) => {
let products = result.items;
});
Cheers!
First, I tried your code but it didn’t work. idk, maybe i’m putting it into the wrong page! i’m running the code into the dynamic page where the grid product gallery put into. i settled it and i started to compile it but with no benefits. could you check that plz ?
Hi @nisccit ,
It is not possible to do what I was asking for. So you can not set the collection to show in the Wix Default Product Gallery by code.
My only possible solution in the end was to build the shop page from scratch using repeaters. Then, you can use the Stores/Products collection dataset and filter those products by collection.
Hopefully that will be added to Wix Stores soon!
Hi @gasparmelsion
This’s insane idk how Wix don’t have this feature beside all of its incredible features???
This’s one of the major feature. How they haven’t think about something like that before. Any one take the decision to open a store in wix has A LOTS of items from different brands. so, by default they added the dynamic page, right? beside the store itself!!!
Ya … we’re actually kind of furious about this after finally finding this post. We just spent the past 48 hours confused that we couldn’t watch enough videos or read enough help pages to figure out how to do this very seemingly, very common sense type of action. Started to think we were crazy. What’s crazy is there’s no apparent way to do this.
IS there a way to do this, people at wix? Is there an upgrade that will make this work? We are on the premium yearly plan.
I just stumbled on the same problem… Sad to see that’s not possible to do.