Content Versioning
SmartEdit allows users to create versions of pages in the staged version of a content catalog.
SmartEdit users can create a version of a page to keep track of the changes made to it. A version is like a snapshot of the content of the page at the time the user creates the version. In content versioning, users can preview page versions, edit page version information such as the page label or description, roll back to a previous page version, or delete a page version.
SAP Commerce Cloud also provides a garbage collection process that periodically cleans up and removes old CMS version entries from the database. This process is configured and accessible in the Backoffice Administration Cockpit. By default, the garbage collection process is enabled and executed once a day.
Page versioning consists of:
- Creating a page version
- Previewing a page version
- Rolling back a page version
- Updating the details of a page version
- Deleting a page version
- Garbage collection of page versions
Creating a Page Version
SmartEdit creates a page version by making a POST request to the Version API. The API uses the CMS Version Service to serialize the page model into a JSON object by inspecting the attributes of the page. Users must provide a version label when creating a page version and an optional description. The CMS Version Service only creates versions of objects that extend from the CMS item type. However, page templates, content slots, and components defined in page templates, as well as restrictions are considered non-versionable, and thus are not versioned. For more information about non-versionable items and how they are handled, see the cmsVersionAttributeToDataStrategyConverter in the CMS Version Service.
Previewing a Page Version
To view a previous version of a page, SmartEdit creates a preview ticket that contains the identifier of the page version by making a POST request to the Preview API. The storefront services pick up the preview ticket, detect that a version identifier is provided, and proceed to call the appropriate methods in the CMS Version Service to retrieve the page version information from the database, deserialize the JSON object into a CMS item model, and return the item model to the storefront for rendering.
Rolling Back a Page Version
To roll back a page to a previous version, SmartEdit makes a POST request to the Version API. The API uses the CMS Version Service to retrieve the page version information from the database, deserialize the JSON object, and update the current page model with the information from the JSON object. SmartEdit also automatically creates a version of the current page before performing the rollback operation. This ensures that no changes on the page are lost and users can roll back to the automatically-saved page in the future as required. Automatically-created versions have a label that starts with "auto-version-" followed by a number that is automatically incremented, for example, auto-version-10.
Homepage Status When Rolling Back a Page
The homepage status of a page does not change when a user rolls back a page to a previous version. Essentially, SmartEdit ignores the homepage flag set in the page version. For example, if the current page is set as the homepage, but the version that the user rolls back to is not a homepage, the page remains a homepage even after the rollback operation. After rolling back, the current page is loaded with the content of the version, but the page remains the homepage.
Updating the Details of a Page Version
When a user updates the details, that is the version label or description of a page version, SmartEdit makes a PUT request to the Version API to update the relevant page version information.
Deleting a Page Version
SmartEdit performs a hard-delete operation when a user deletes a page version. It makes a DELETE request to the Version API to delete the entry from the database. Any versions that are permanently deleted cannot be restored or recovered.
Garbage Collection of Page Versions
SmartEdit uses a CMS Version garbage collection process to periodically clean up and remove old CMS versions to keep SAP Commerce Cloud running smoothly. The CMS version garbage collection process is enabled by default to run daily. The CMS version garbage collection process can also be started manually from the Backoffice Administration Cockpit. For more information about the CMS version garbage collection process, see Garbage Collection.
Related Documentation
The following documentation provides information about the services and APIs used in the implementation of content versioning: