Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.
Solved

Setting the owner of a metaobject

ejb1
Shopify Partner
6 1 0

I'm wanting to create metaobjects owned by pages (like can be done with metafields), but I can't see any information on how to do this.

 

The metaobjects introduction says this: 

Similar to metafields , they can be associated with a Shopify resource such as a product or a collection.

but there is no other reference to this anywhere else in the metaobjects docs. The only way I can see to connect an object to a resource is by setting a metafield with a metaobject reference on the resource, but this seems like a strange way for this to work and, I assume, won't delete the metaobject when the resource is deleted.

 

Am I missing something or is there really no way to properly associate a metaobject with a resource?

Accepted Solution (1)
SBD_
Shopify Staff
1812 266 390

This is an accepted solution.

From the Metaobjects team:
---

Yep that’s exactly how you do it

and, I assume, won't delete the metaobject when the resource is deleted

This is also correct.

 

The key idea is that each metaobject definition is a new “resource/primitive”, and thus its entries are global, hence you can only create references to it.

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 2 (2)

SBD_
Shopify Staff
1812 266 390

Hey @ejb1 

 

The only way I can see to connect an object to a resource is by setting a metafield with a metaobject reference on the resource.

I think that might be the case - double checking with the Metaobjects team and will report back.

Scott | Developer Advocate @ Shopify 

SBD_
Shopify Staff
1812 266 390

This is an accepted solution.

From the Metaobjects team:
---

Yep that’s exactly how you do it

and, I assume, won't delete the metaobject when the resource is deleted

This is also correct.

 

The key idea is that each metaobject definition is a new “resource/primitive”, and thus its entries are global, hence you can only create references to it.

Scott | Developer Advocate @ Shopify