Remove metafield from product content

Even when you remove the code of the meta field from product content, it's still there in the database. 


So we need the scripts to complete removing them in both Commerce and CMS:
  • For Commerce:
DECLARE @MetaFieldId INT = 80 

DELETE FROM MetaDictionary WHERE MetaFieldId = @MetaFieldId 
DELETE FROM CatalogContentProperty WHERE MetaFieldId = @MetaFieldId 
DELETE FROM ecfVersionProperty WHERE MetaFieldId = @MetaFieldId 
DELETE FROM MetaClassMetaFieldRelation WHERE MetaFieldId = @MetaFieldId 
DELETE FROM MetaField WHERE MetaFieldId = @MetaFieldId 

EXEC mdpsp_sys_ClearMetaAttribute @MetaFieldId, 2
  • For CMS:
exec netPropertyDefinitionDelete @PropertyDefinitionID=2699
 
 

If the meta field is not completely removed, the meta field will be re-creating/re-appearing in `tblPropertyDefinition` in CMS when you restart the site:

declare @p1 int 
set @p1=2702 
declare @p16 int 
set @p16=7 
declare @p17 int 
set @p17=NULL 
exec netPageDefinitionSave @PageDefinitionID=@p1 output,@PageTypeID=158,@Name=N'ProductTeaser',@PageDefinitionTypeID=37,@Required=NULL,@IsList=NULL,@Advanced=NULL,@Searchable=NULL,@DefaultValueType=0,@EditCaption=NULL,@HelpText=NULL,@ObjectProgID=NULL,@LongStringSettings=0,@SettingsID=NULL,@FieldOrder=0,@Type=@p16 output,@OldType=@p17 output,@LanguageSpecific=4,@DisplayEditUI=NULL,@ExistsOnModel=1,@EditorHint=NULL,@ImageDescriptor=NULL,@Saved='2024-02-28 09:17:34.663' 
select @p1, @p16, @p17

Comments

Popular posts from this blog

Optimizely Content Graph: minimal setup for testing

Episerver ServiceAPI: Example of how-to properly call the media upload

SameSite Cookie login troubleshooting