metafield collection list, how to retrieve collection data

Solved

metafield collection list, how to retrieve collection data

XavierTsang
Shopify Partner
2 0 0

Collection setting I have a metafield named child_collection_list which let user self define child collection to be show on collection page

from collection page I obtain it by
{% assign child_collection = collection.metafields.custom.child_collection_list %}
its value in string format
["gid://shopify/Collection/563659761","gid://shopify/Collection/563659794","gid://shopify/Collection/563659827"]

I split and reformat it in ID array
and use colections object to retrieve the data like {{ collections['563659761'].handle }}

but I meet the 1000 max result set limitation

is there have any direct method to retrieve the collection object by collection's handle or id from section liquid ??


Accepted Solution (1)

Huptech-Web
Shopify Partner
1169 234 264

This is an accepted solution.

Hi @XavierTsang 
You can use for loop to retrive collection Object, Check the below code

{% assign child_collection = collection.metafields.custom.child_collection_list.value %}
{% for collection in child_collection %}
  {{ collection.title }}
{% endfor %}
If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required

View solution in original post

Replies 3 (3)

Huptech-Web
Shopify Partner
1169 234 264

This is an accepted solution.

Hi @XavierTsang 
You can use for loop to retrive collection Object, Check the below code

{% assign child_collection = collection.metafields.custom.child_collection_list.value %}
{% for collection in child_collection %}
  {{ collection.title }}
{% endfor %}
If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
XavierTsang
Shopify Partner
2 0 0

Thx for reply, I missing the .value can't return collection object

Huptech-Web
Shopify Partner
1169 234 264

You're welcome @XavierTsang 
To fetch collections object you need to pass .value in metafield
You can find more here: https://shopify.dev/docs/api/liquid/objects/metafield#metafield-value

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required