Try our conversational search powered by Generative AI!

Removing a property that no longer exists in the code

Vote:
 

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?

#299587
Apr 05, 2023 15:07
Vote:
 

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

#299648
Edited, Apr 06, 2023 8:44
Vote:
 

@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.

#299720
Apr 07, 2023 9:27
Vote:
 

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?

#299833
Apr 10, 2023 14:02
Vote:
 
#299898
Apr 11, 2023 9:01
Vote:
 

@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?

#299918
Apr 11, 2023 13:08
Vote:
 

Yes!

#299920
Apr 11, 2023 13:39
Vote:
 

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?

#301560
May 12, 2023 7:06
Vote:
 

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

https://we.tl/t-uU2qrFqXi8 

#301570
May 12, 2023 9:02
Kristoffer Persson - Oct 02, 2023 13:51
The link is dead. Any chance this made it to a NuGet package?
Scott Reed - Oct 02, 2023 17:14
https://we.tl/t-uebBZGR2Qz I've uploaded it again
Calvin Ells - Apr 02, 2024 19:24
Any chance this is available as a Nuget package yet?
Thanks.
Vote:
 

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.

#302552
May 29, 2023 12:11
Scott Reed - May 30, 2023 13:50
Excellent, I keep meaning to pop it out as an official nuget package when we get the time!
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.