Dynamically Modify a Collection

kallenconsult
Excursionist
28 0 8

I've been looking for ways to programatically have a "scratch" collection that I could use to access data from various products, depending on dynamic criteria at runtime.

 

Is there a way to assemble or modify a collection of products based on their GID?  Our site uses the bundler app to offer a group of products to be sold as a single product and I want to pull metadata from each product in the bundle.   I can get the GID of each product but haven't been able to create an array of product objects to pull info from, so it seemed a temporary/scratch collection (if it can be done) could fit the bill.

 

Any help would be greatly appreciated!

Replies 5 (5)
zaczee
Globetrotter
749 41 35

Hi,

 

Can you provide your store url

kallenconsult
Excursionist
28 0 8

Ya know, it seems silly that one would need our store URL to answer this theoretical question but it also seems to be the first question anyone asks.  What's up with that?

gr_trading
Shopify Partner
1394 130 151

Hi kallenconsult ,

 

Can you clarify GID in your statement it seems to be product id, whereas I thinking of its unique userid.

 

 

Here is the flow,

 

Seems you want a collection of product which user has visited, or you want to show the group of product which has similar meta info.

 

Please clarify?

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | YouTube Videos
To support Buy Me a Coffee
kallenconsult
Excursionist
28 0 8

In contemporary coding, a "gid" is a uniquely generated identifier for data.

What is a GID?

In this context, it is returned from a product object as a unique identifier for that product.

 

My original goal was to assemble an array of objects based on some criteria and then iterate through the array.  But liquid being what it is, that's not quite so simple,  One thing is we can't seem to create an object (product or otherwise) on the fly.  However, you can iterate through a collection of products and get the product object -- but if I can't modify the collection at runtime, that's a dead end.

gr_trading
Shopify Partner
1394 130 151

Can you share your logic you want.

May be we could suggest something around it.

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | YouTube Videos
To support Buy Me a Coffee