Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
I wish to reorder my product images so the GLB is the first image. However when I look at the fields for Media, the Model3d is missing and id field. How do I move the GLB without an id field to select? I also get the error "Field 'id' doesn't exist on type 'Media'",
fragment fieldsForMediaTypes on Media {
alt
mediaContentType
preview {
image {
id
altText
originalSrc
}
}
status
... on Video {
id
sources {
format
height
mimeType
url
width
}
originalSource {
format
height
mimeType
url
width
}
}
... on ExternalVideo {
id
embeddedUrl
}
... on Model3d {
sources {
format
mimeType
url
}
originalSource {
format
mimeType
url
}
}
... on MediaImage {
id
image {
altText
originalSrc
}
}
}
The ID field does exist according to the API reference. This must be a typo in the example.
I found the original example here: https://shopify.dev/tutorials/manage-product-media-with-admin-api
The only gid I see is for the preview jpg, which is invalid for reordering.
This is my query. How do I get the id?
query = '''query($id: ID!){
product(id: $id) {
title
media(first:1) {
edges {
node {
... fieldsForMediaTypes
}
}
}
}
}
fragment fieldsForMediaTypes on Media {
alt
mediaContentType
preview {
image {
id
altText
originalSrc
}
}
status
... on Model3d {
id
sources {
format
mimeType
url
}
originalSource {
format
mimeType
url
}
}
}
Hey @BeamJokerFavor,
What's the response you're getting with that fragment?
Here's mine, which does return the model3d's id, using a very similar request without preview images:
{
product(id:"gid://shopify/Product/5611962236950") {
title
media(first:1) {
edges {
node {
... fieldsForMediaTypes
}
}
}
}
}
fragment fieldsForMediaTypes on Media {
alt
mediaContentType
status
... on Model3d {
id
sources {
format
mimeType
url
}
}
}
response:
{
"data": {
"product": {
"title": "Pot and Saucer",
"media": {
"edges": [
{
"node": {
"alt": "",
"mediaContentType": "MODEL_3D",
"status": "READY",
"id": "gid:\/\/shopify\/Model3d\/20164237459478",
"sources": [
{
"format": "glb",
"mimeType": "model\/gltf-binary",
"url": "https:\/\/model3d.shopifycdn.com\/models\/o\/517cffab171ed5bb\/pot-saucer.glb"
},
{
"format": "usdz",
"mimeType": "model\/vnd.usdz+zip",
"url": "https:\/\/model3d.shopifycdn.com\/models\/o\/b6e27223f40e2e06\/pot-saucer.usdz"
}
]
}
}
]
}
}
}
}
CalD | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Yes, I was able to get the ID to appear. I think the problem was I copied-and-pasted the example. I added the field back and it appeared. Thank you for your help and sorry for the trouble.
I am having trouble finding GLBs, even though I am looking at them in my Shopify inventory. My goal is to strip GLBs from archived product.
This is my query:
'''query GetAllGlbs($id: ID!){
product(id: $id) {
title
media(first:15,) {
edges {
node {
... fieldsForMediaTypes
}
}
}
}
}
fragment fieldsForMediaTypes on Media {
alt
mediaContentType
status
... on Model3d {
id
}
}
'''
What I think this does is that it only returns the GLB id if the item type is Model3D. Then I sort the products into a list of GLB image ids and a list of product gids without GLBs.
list_images = r_json['data']['product']['media']['edges']
print(f'len images: {len(list_images)}')
for edge in list_images:
try:
#if edge['node']['mediaContentType'] != 'IMAGE':
glb_list.append(edge['node']['id'])
with_glb.append(gid)
print('found')
break
except KeyError:
pass
without_glb.append(gid)
This code makes no hits on GLBs and marks all products as without GLBs. Something is incorrect. Do you see where the mistake is?
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By