Skip to content

Instantly share code, notes, and snippets.

@fluxdigital
Created July 6, 2022 15:47
Show Gist options
  • Save fluxdigital/24288afc177a615d798e6ce22414fb2f to your computer and use it in GitHub Desktop.
Save fluxdigital/24288afc177a615d798e6ce22414fb2f to your computer and use it in GitHub Desktop.
<#
Function used to move preview site to the top of the list
#>
function Move-Preview-Site-To-Top($newSiteId){
$sxaSitesList = Get-Item -Path "master:/sitecore/system/Settings/Foundation/Experience Accelerator/Multisite/Management/Sites"
$orderValuesCurrent = $sxaSitesList.Fields["Order"].Value;
write-host "New Site ID: $($newSiteId)"
write-host "Current Order Values: $($orderValuesCurrent)"
if (![string]::IsNullOrEmpty($orderValuesCurrent) -and $newSiteId)
{
$orderValues = "$($newSiteId)|$($orderValuesCurrent)"
$sxaSitesList.Editing.BeginEdit()
$sxaSitesList.Fields["Order"].value = $orderValues
$sxaSitesList.Editing.EndEdit()
write-host "New Order Values Set: $($orderValues)"
}
else{
write-host "New Order Value Not Set: $($orderValuesCurrent)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment