Get Collection from ID

Shopify Partner
3 0 5

Goal: I want to use the id of a collection from within liquid to get the collection object.

I want to use meta fields to create a reference to a collection. I could easily use the collection handle but that can change which would break the link. The collection id does not change so it makes much more sense to use the id (since it is the id after all).  From within liquid I can get a collection from the handle but is there a way to get it from the collection id?

Shopify Expert
9807 92 1560

Hey Jason,

For the storefront and Liquid you'll need to use the handle to reference the collection.

In the unlikely scenario where you have less than 51 collections you could use the ID. In that case the code would loop over the 50 collections and match the id to a handle. Once you've got the handle you use the standard referencing method.

★ Winning Partner of the Build a Business competition. ★
New Member
4 0 0

Jason can you tell me where you get the Storefront Collection ID ? will loop into it is very good approach ... i also need same scanrio please let me know the storefront collection id where can i get.