Created
          September 4, 2017 12:47 
        
      - 
      
- 
        Save StefanoChiodino/f37168fb6f1b731d75d22e78833d6126 to your computer and use it in GitHub Desktop. 
    A quick script to export all vorto values
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var allNodes = UmbracoContext.ContentCache | |
| .GetByXPath("//*[@isDoc]"); | |
| var nodesVortoValuePairs = allNodes | |
| .SelectMany(n => n.Properties | |
| .Where(p => p.Value is Our.Umbraco.Vorto.Models.VortoValue) | |
| .Select(p => new { Node = n, Property = p })); | |
| var vortoValuesExport = nodesVortoValuePairs | |
| .Select(a => | |
| { | |
| var vortoValue = | |
| a.Property.Value as Our.Umbraco.Vorto.Models.VortoValue; | |
| var containsKey = vortoValue?.Values?.ContainsKey("en-US"); | |
| var translatedPropertyValue = (containsKey != null && containsKey == true) | |
| ? vortoValue.Values["en-US"] | |
| : null; | |
| return new | |
| { | |
| NodeId = a.Node.Id, | |
| NodeName = a.Node.Name, | |
| NodeUrl = a.Node.Url, | |
| PropertyAlias = a.Property.PropertyTypeAlias, | |
| PropertyUsValue = translatedPropertyValue | |
| }; | |
| }) | |
| .ToList(); | |
| var vortoValueJsonExport = JsonConvert.SerializeObject(vortoValuesExport); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment