Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sitecore Commerce 8.2.1 Staging with SPE
A SPE module that provides a dialog to stage (publish) Sitecore Commerce 8.2.1 catalog data
Import-Function Get-StagingProjects
Get-StagingProjects |
Show-ListView -Property Name, Status
Close-Window
function Get-StagingProjects {
param()
$getProjectsArgs = [Sitecore.Commerce.Connect.CommerceServer.Staging.Pipelines.GetAllCommerceStagingProjectsArgs]::new()
[Sitecore.Pipelines.CorePipeline]::Run("GetAllCommerceStagingProjects", $getProjectsArgs)
$getProjectsArgs.OutputParameters.ProjectNames |
Foreach {
[StagingProject]@{
Name = $_
Status = (Get-StagingProjectStatus $_)
}
}
}
function Get-StagingProjectStatus {
param(
[string] $projectName
)
$getStatusArgs = [Sitecore.Commerce.Connect.CommerceServer.Staging.Pipelines.GetCommerceStagingProjectLocalStatusArgs]::new()
$getStatusArgs.InputParameters.ProjectName = $projectName;
[Sitecore.Pipelines.CorePipeline]::Run("GetCommerceStagingLocalProjectStatus", $getStatusArgs)
$getStatusArgs.OutputParameters.Status
}
class StagingProject {
[ValidateNotNullOrEmpty()][string]$Name
[ValidateNotNullOrEmpty()][string]$Status
}
Import-Function Get-StagingProjects
Get-StagingProjects | Update-ListView
Import-Function Get-StagingProjects
$projects = if ($selectedData) { $selectedData } else { $allData }
for ($i = 0; $i -lt $projects.Length; $i++) {
$projectName = $projects[$i].Name
Write-Progress -Activity "Running Staging Projects" -Status "$($i + 1) of $($projects.Length) Projects" -PercentComplete (($i/$projects.Length) * 100) -CurrentOperation $projectName
$startStagingArgs = [Sitecore.Commerce.Connect.CommerceServer.Staging.Pipelines.StartCommerceStagingProjectArgs]::new()
$startStagingArgs.InputParameters.ProjectName = $projectName;
[Sitecore.Pipelines.CorePipeline]::Run("StartCommerceStagingProject", $startStagingArgs)
}
Get-StagingProjects | Update-ListView
Write-Progress -Activity "Running Staging Projects" -Completed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment