Sitecore Commerce 8.2.1 Staging with SPE

  

If you are still using Sitecore Commerce 8.2.1, you may find this SPE module helpful. It provides a dialog that will allow you to stage (publish) your catalog.

I had planned to write this blog post quite a while ago. I hesitated because Commerce 8.2.1 is not the latest and greatest toy on the shelf. However, the past couple of weeks, I have been installing Commerce 8.2.1 on a new set of servers for my current client. Perhaps I am not the only one out there that is still working on this old version of Sitecore Commerce.

When setting up Sitecore Commerce 8.2.1 for a scaled environment, you typically set up two “sites”: an authoring site for CM and a shops site for CD. Each site is set up with its own catalog database and the legacy Commerce Server Staging Service is used to publish catalog data from the authoring catalog database to the shops catalog database.

When you install the Commerce Packages, they add a customized version of the Publish dialog that allows you to run your Commerce Staging projects. However, if you then install the Publishing Service, you will lose this ability because the Publishing Service has it’s own custom dialog. To remedy this situation, I decided to add a button to the Sitecore Commerce ribbon strip with Sitecore PowerShell Extensions.

I created a PowerShell Script Module that contains fairly 4 simple scripts:

The Get-StagingProjects script does most of the interesting work. I separated this out into a Functions script so that I could import it for use in each of the other scripts.

This script runs the GetAllCommerceStagingProjects pipeline to get the Staging Projects that have been defined using the Commerce Server Staging Manager and then iterates over each of the results to get the project status via the GetCommerceStagingLocalProjectStatus pipeline. While the script supports multiple staging projects, I think most people will only have one.

The button script simply imports the function script and pipes the result to Show-ListView. The Close-Window Command is called to close the progress window that appears while the dialog is loading.

When you click the ribbon button, a list view dialog opens as shown below.

There are two custom actions defined for this dialog: Refresh and Start Staging. The Start Staging script uses the StartCommerceStagingProjectArgs pipeline to start staging each of the selected projects. If no projects are selected, then all of the projects are staged. The project list and statuses are updated after the staging projects have been started.

The staging projects usually take a few seconds at least to complete, so the statuses will usually show as In Progress after they have been started. The Refresh button will reload the projects and their status so that you can see if they have completed.

If you think that this script module would be helpful, please feel free to download this package. It contains both the script items and the ribbon button items that it generates.