Liquid, JavaScript, themes, sales channels
Hello so after going through the Shopify support and being unable to resolve the conundrum we have I am here to post to see what can we do and what do we have available to delete metafields without definition. Now I noted to Shopify that the current state of their integrated metafields is seriously lacking and that is an understatement. There is no pagination, we have only 10 fields loaded per view. To get new metafields into the view and to define them we need to define all the previous ones or atleast 1 by 1. Our issue happened when our POS imported some metafields that do not play well with Shopify.
Luckily enough all 10 we can see are bugged and we cannot add definition to them so we can delete both the metafield and the definition. Now current issue is what we are having is we cannot see our other 190 fields because our first 10 are bugged. That is problem number one. Problem number two is we can only delete metafields and/or their definitions once we actually define the metafield which we again cannot due to the fact our first 10 metafields are bugged. I have investigated the Shopify api and there is nowhere an endpoint in which i can get all of my stores undefined metafields currently and delete them. Does anyone have any idea how we can clean this up without recreating the store because we had a massive migration done which we will not do again.
It is a fact we will be switching to a 3rd party plugin for metafields but I'm just curious here when will native metafields be really correctly usable and I am hoping someone has a suggestion how i can do a complete cleanup of my undefined metafields for the store. Maybe there is some api endpoint that is not in the documentation i can hit so i can DELETE or something like that.
Thanking you all in advance
Warning be super careful to avoid removing metafields used by apps
You would need to setup and app go through the api for each resource(products,collections,orders,etc) getting it's metafields then checking the metafields as being standard metafields or definitions
https://shopify.dev/apps/metafields/definitions
Without your own app , something like matrixify you can use CSVs and excel to prune things
https://matrixify.app/tutorials/import-export-and-update-shopify-shop-metafields-in-bulk/
And something like this should be possible to automate with a usemechanic script
Example https://tasks.mechanic.dev/delete-product-or-product-variant-metafields-in-bulk
Though when sanitizing data be super careful not to delete metafields required by apps your business relies on to function on a daily basis.
If you need something like this explored contact me at paull.newton+shopifyforums@gmail.com to setup a consult to get into details.
Save time & money ,Ask Questions The Smart Way
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org
Hey @GoranHorvat
Renars here from Matrixify.
Thank you for mentioning us here @PaulNewton
You sure can bulk remove Metafields from Products with our app, but as @PaulNewton mentioned, you would need to be careful not to remove value from the ones that do have definitions.
Metafields without definition, do not exist really separately in Shopify, but for each product individually, so the task would be to remove it from each Product.
The tutorial linked above would be for Shop level metafields specifically, but here is a better tutorial that you can go through that specifically explains how to remove Product metafields - How to manage Shopify Metafields.
Just make sure that before importing any file that removes values from Metafields, double-check that those Metafield columns are actually for Metafields that are not definitions.
If you need more assistance or help with that, please reach out to our support directly!
Would you happen to have a simple API script that would delete all metafields with 0 as the value?
I would most likely use your suggestion of usemechanic to impliment it, but looking for recommendations for code.
Thanks in advance!
Cheers
Chris
So the apparently the only way to delete a metafield without a definition is to first ADD a definition. Save it and then Delete.
Be sure to select "Delete field and its saved values" or it wont actually delete.
Not super intuitive or user friendly. But it works.
Thank you 😊
You CAN do this using Matrixify. And that is a LOT quicker than doing it manually. I had over 200 metafields without definitions from an import of WooCommerce products when migrating. Nightmare!
Theory
First, you need to understand that a metafield without a definition is just a bit of data stored against an object (e.g. a product), in a non-structured way. I.e. Shopify has that data, but you haven't told it anything about what that data is (i.e. you haven't added a definition), so its not useable.
Why is that important? Because it means that by simply deleting the data, i.e. the VALUES, the metafield will also be removed.
How to remove them
Follow this guide and make sure to select "Export metafields without definitions" - do this for the relevant object e.g. Products.
https://matrixify.app/tutorials/how-to-manage-shopify-metafields/
Then, in your file make sure to remove all columns for metafields you want to KEEP. Fully delete these columns from the file, so that when we re-import we do not affect them in any way.
Then, for the metafields without definitions that you want to remove (which should all be listed at the top as columns), delete all the data in the rows below. So you will have the column, with the metafield name at the top, but no data in any of the rows within that column.
Then you can save and reimport this.
This will essentially tell Shopify to update this metafield with BLANK data. By doing this, the metafield is also removed.
Simple!
User | RANK |
---|---|
37 | |
25 | |
14 | |
13 | |
9 |
Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023