Last active
August 22, 2016 16:45
-
-
Save AdamNaj/0182004fadb95544be5ef1bf520cb547 to your computer and use it in GitHub Desktop.
ZG Showcase migration
This file contains 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
$orderNo=0 | |
$siteDef = gci "master:\content\Showcase Group\Showcase\int\home" -Recurse | | |
? { $_.Name -ne "Data" -and $_.Parent.Name -ne "Data" -and $_.Parent.Parent.Name -ne "Data" -and $_.Parent.Parent.Parent.Name -ne "Data" -and $_.Parent.Name -ne "Page Data" -and $_.Visualization.Layout -ne $null} | | |
%{ | |
$orderNo++; | |
$pageDefinition = [ordered]@{ | |
Name="$($_.Name)"; | |
DisplayName="$($_.DisplayName)"; | |
__Icon="$($_.Appearance.Icon)"; | |
Path="$($_.Parent.Paths.FullPath.Substring(50))"; | |
TemplateName="$($_.TemplateName)"; | |
Title="$($_.Title)"; | |
OrderNo="$orderNo"; | |
__Sortorder="$($_.__Sortorder)" | |
}; | |
$fields = gci "master:\content\Showcase Group\Showcase\int\home" | Get-ItemField | |
foreach($field in $fields){ | |
$pageDefinition.$field = $_[$field]; | |
} | |
return New-Object -TypeName PSObject -Prop $pageDefinition | |
} | | |
ConvertTo-Json | |
$siteDef | Set-Content $SitecoreDataFolder\Showcase.json | |
Download-File -Path "$SitecoreDataFolder\Showcase.json" -NoDialog |
This file contains 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
$pages = Get-Content -Path C:\tmp\Showcase.json | ConvertFrom-Json | |
gci master:\content\Showcase\Showcase\International\Home | ? {$_.TemplateName -eq "Page" } | Remove-Item -Recurse -Force | |
$i=0 | |
foreach($page in $pages){ | |
$i++ | |
try{ | |
$parentPath = "master:\content\Showcase\Showcase\International\Home$($page.Path)"; | |
if(Test-Path -Path $parentPath){ | |
$item = New-Item -Path "master:\content\Showcase\Showcase\International\Home$($page.Path)" -Name ($page.Name) -ItemType "Project/Showcase/Showcase/Page" | |
$item.Title = $page.Title | |
$item.NavigationTitle = $page.Title | |
$item.'__Display name' = $page.DisplayName | |
$item.__Icon = $page.__Icon | |
$item.__Sortorder = $page.__Sortorder | |
} | |
else{ | |
Write-Host "Skipping '$($page.Path)\$($page.Name)' - Parent not found" -ForegroundColor Red | |
} | |
} catch{ | |
Write-Host "Null page at position $i (OrderNo: $($page.OrderNo))" | |
} | |
} | |
Write-Host "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment