Computed field help

Hi guys! I'm trying to write a computed field on shopifyShop to check the amount of missing product alt texts in the store. I had this in the past but now that it changed to product media I'm not being able to write it. Can you help?
15 Replies
Chocci_Milk
Chocci_Milk6mo ago
Hello, ShopifyFile has an alt field. I think that you should be able to use that.
Chocci_Milk
Chocci_Milk6mo ago
No description
Chocci_Milk
Chocci_Milk6mo ago
You might have to check the mimetype though You can probably use the startsWith function to see if the mimetype starts with image
Rena
RenaOP6mo ago
Can you write a quick example? I tried but I suck at gelly honestly I need it to be exclusively product images not any images
Chocci_Milk
Chocci_Milk6mo ago
field on shopifyShop {
count(files, where: <filter here>)
}
field on shopifyShop {
count(files, where: <filter here>)
}
Rena
RenaOP6mo ago
That's why I mentioned product media
Chocci_Milk
Chocci_Milk6mo ago
the filter should probably check that productId is set and that the mimetype starts with image
Rena
RenaOP6mo ago
Great thank you
Chocci_Milk
Chocci_Milk6mo ago
and obviously that alt isnt set
Rena
RenaOP6mo ago
Hi @Chocci_Milk, any ideas?
No description
Chocci_Milk
Chocci_Milk6mo ago
You need to specify that alt is on file
Rena
RenaOP6mo ago
We tried a lot of things but cannot link file with product field on shopifyShop { productMedia { file { count(id, where: (isNull(alt) || alt == "") && startsWith(mimetype, prefix: "image")) } } } Not sure how to check if the file is associated with a product using gelly Tried multiple approaches
Chocci_Milk
Chocci_Milk6mo ago
What I wrote is what you should be using at base Your filters are incorrect and should always target the model: ie files.alt Do you only want productMedia or do you also want productVariantMedia?
Rena
RenaOP6mo ago
All images associated with a product or variant If you check the image I tested what you wrote or at least tried haha
Chocci_Milk
Chocci_Milk6mo ago
Yeah so productMedia is only on the product. That's why I was going by file

Did you find this page helpful?