There's no admin way of doing it, you need to delete via code https://world.optimizely.com/blogs/stackmanoz/dates/2023/2/deleting-missing-metafields-in-code-programmatically/
Usually adding something like this to an admin tool or an init module
@Scott
Thanks for the response. In the title I see "Deleting missing metafields in code programmatically", but from the article I only learned how to detect properties that are still in the database, but not in the code. How to get rid of such unused properties?
In my case, after using Commerce for a long time, I am dealing with properties that are not used - sometimes they are single, sometimes there are more. I would like them not to be displayed as well as get rid of them from the database to speed up the performance of the products - currently, by handling existing obsolete properties, the products seem to run slower.
Which field are you attempting to remove in commerce?
Field you've added to an Entry or node type by code?
FIeld you've added as a metafield to a metaclass?
I wrote this Delete property no longer available in code – Quan Mai's blog (vimvq1987.com) which might help
@Surjit
I mean fields of classes inheriting from EPiServer.Commerce.Catalog.ContentTypes.ProductContent. Classes marked with an attribute CatalogContentType.
[Display(
Name = "My property",
Description = "My description.",
GroupName = Tabs.Overview,
Order = 10)]
public virtual string MyProperty { get; set; }
@Quan
This looks helpful. Thank you. I understand that as a parameter I should pass the name of a property from the code that existed and was removed?
I looked at both https://world.optimizely.com/blogs/stackmanoz/dates/2023/2/deleting-missing-metafields-in-code-programmatically/ & https://vimvq1987.com/delete-property-no-longer-available-in-code/ articles and they seem to work only if there's no data stored on that metafield.
Any idea what would be the proper delete approach for a metafield which is no longer needed but has data stored on it?
We built an admin tool which lists all the missing properties and can force delete them and I'm pretty sure it works even with data existing
Thanks Scott,
In inital testing, the tool you've provieded worked flawlessly :)
I might need to change a thing or two for my solution, but overall looks great and probably should be a part of standard package.
A property that existed in the code and then was removed still appears on the product in Commerce.
In CMS it is possible according to the instruction:
https://support.optimizely.com/hc/en-us/articles/13750995913997-Deleted-fields-still-displaying-in-CMS
What is the official recommended way to remove such a field in Commerce 14?