What's your biggest current challenge? Have your say in Community Polls along the right column.

How can I display a list of product releases on an Artist metaobject page?

How can I display a list of product releases on an Artist metaobject page?

julianwayu
Shopify Partner
1 0 1

I have have metaobjects that references a list of products.

 

For example:

I have created a "Artist" metaobject

This metaobject has some fields such as name, location and releases.

 

Releases is a list of references to products "Releases" for that specific artist. 
In the admin for example i can see a list of all the products being referenced for that artist, but i havent been able to find a way to do the same on my template. where i want to list all the releases that artist has when user goes to the Artist metaobject page. 

See screenshot of how it looks in the admin:
Screenshot 2024-02-21 at 8.01.06 PM.png


Replies 4 (4)

alfablue
Shopify Partner
1 0 1

Hello,

I have the same question.

Can't find an answer on the documentation.

lojainusual
Tourist
5 0 2

Same here. Can't access these references.

 

The only way we could accomplish this is to create a category with all the products for that metaobject and then assign it to the metaobject itself. But this way we are having more work.

But personally I don't think it makes sense. There should be a way to access the products referenced by a metaobject

ReverseTurtle
Shopify Partner
2 0 0

Yeah, how is this not an option? Literally the reason the references are there.

ri31
Shopify Partner
7 0 2

This is possible.

 

Here is some code to get you started. It will pull in a list of products and the URL, featured image, title, and description for each of them. Then you can use CSS to customize the appearance or figure out how to pull in different data fields from the products and reorder them.

 

{% paginate collections["all"].products by 3000 %}

{% for product in collections.all.products %}

{% if product.metafields.custom.METAFIELD_NAME_HERE.value.title == metaobject.title %}

<a href="{{product.url}}">
<div class="repeater-card">
<img src="{{product.featured_image | image_url }}" width="200px" height="200px">
<h4>{{ product.title }}</h4>
<p>{{ product.description }}</p>
</div>
</a>

{% endif %}

{% endfor %}

{% endpaginate %}