Convert single page PageType to another PageType programically

Vote:
 

Hello,

i found the topic https://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2018/5/convert-page-type-to-another-page-type-programmatically/ where there is described that we could migrate single page to another pagetype.

My question is --> there is talking about " List<KeyValuePair<int, int>> propertyTypeMap" . How could get this one? I mean it's strange that we are using int instead of string (since i don't know how to get int of my propertyname in my page).
Is there some kind of epi method that i could get Page property int value ??

#200945
Jan 31, 2019 12:58
Vote:
 

You can use IPropertyDefinitionRepository to list all properties for a page type.

var pageTypeId = 10;
var propertyDefinitions = propertyDefinitionRepository.List(pageTypeId);
var property = propertyDefinitions.FirstOrDefault(x => x.Name == "NameOfProperty");
var propertyId = property.ID;
#200950
Edited, Feb 04, 2019 10:15
* 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.