Spartacus Sample Data Extension
Note: Spartacus 4.x is no longer maintained. Please upgrade to the latest version.
Note: Spartacus 4.x was tested with SAP Commerce Cloud versions 1905 to 2205. Spartacus 4.x has not been verified to work with (and is not guaranteed to work with) SAP Commerce Cloud 2211 or later releases.
spartacussampledata extension creates new WCMS base sites for Spartacus that share the same product catalog with the default
powertools sites, but with content catalogs that have been modified specifically for Spartacus requirements.
Table of Contents
- Downloading the Spartacussampledata Extension
- CMS Changes Specific to the Spartacus Project
- Removing Unused Pages, Content Slots and CMS Components
- Replacing the JspIncludeComponent with the CMSFlexComponent
- Adding Data into the
- Replacing the Homepage Preview Image
- Adding a SiteContext Slot with New Components to Each Template
- Updating the MiniCartSlot
- Adding CMSlink Components to a New SiteLinks Slot
- Creating New CMS Pages
- Adding More Content to the “Not Found” Page
- Adding a SignOutLink in My Account
- Updating the Breadcrumb in Spartacus
- Updating Page Labels to Start with a Forward Slash
- Adjusting the Searchbox Component Configuration
- Making CMS Changes Related to Checkout
- Making the Product Details Page CMS-Driven
Downloading the Spartacussampledata Extension
You can download the Spartacus Sample Data extension from the Spartacus Releases page.
The Spartacus Sample Data extension is versioned and released with the Spartacus
storefront library. You can download the latest version by clicking on
spartacussampledata.zip in the Assets section of the most recent release of the
Of course, previous versions are also available. For example, to download the Spartacus Sample Data extension for the
3.0.0-RC.1 release, you can access the Assets section of the
@firstname.lastname@example.org library here.
For more information about installing the
spartacussampledata extension, see Installing SAP Commerce Cloud for use with Spartacus.
The following diagram demonstrates how the
Electronics-Spa base site is created. The process is similar for all sample stores.
Note: The ImpEx file paths in the following sections are to a
spartacussampledata extension that has been installed with SAP Commerce Cloud.
spartacussampledata extension does the following:
Creates new base sites called
powertools-spa, if these sample stores are configured in your
extensions.xml. See the
site.impexfile for each base site in the
resources/spartacussampledata/import/storesfolder for details.
Creates a new
catalogVersions(Staged and Online). See the
catalog.impexfile for each base site in the
resources/spartacussampledata/import/contentCatalogs/folder for details.
CatalogVersionSyncJobthat can sync
[samplestore]-spaContentCatalog:staged. See the
sync.impexfile for each base site in the
resources/spartacussampledata/import/contentCatalogsfolder for details.
spartacussampledata extension includes the
SpaSampleAddOnSampleDataImportService, which extends
DefaultAddonSampleDataImportService. It overrides the default
importContentCatalog function, so that during system initialization or system update, the
importContentCatalog function does the following:
- creates a new catalog
- performs some cleaning
- imports the content catalog from impex
- gives permission to the
cmsmanagerto do the synchronization
- imports email data
Note: To ensure these actions are performed during a system update, you must check the box next to the relevant storefront(s) you wish to update before pressing Update in the hybris administration console, as shown in the following example:
CMS Changes Specific to the Spartacus Project
[samplestore]ContentCatalog:Staged is synchronized to
[samplestore]-spaContentCatalog:Staged, the initial data is the same in both content catalogs. But, to make Spartacus work better, the
-spa versions contain different CMS data. Changes are made on the
[samplestore]-spaContentCatalog, which are described in the following sections.
Removing Unused Pages, Content Slots and CMS Components
Spartacus does not contain all of the pages that are found in Accelerator. The unused pages, content slots, and CMS components are removed from the
[samplestore]-spaContentCatalog. You can check the
cleaning.impex file for each base site in the
resources/spartacussampledata/import/contentCatalogs/electronicsContentCatalog folder to see what is removed.
Replacing the JspIncludeComponent with the CMSFlexComponent
JspIncludeComponent allows you to include JSP code when you provide the path of the JSP file that then gets inserted. It does not make sense to have this type of component in the Spartacus Angular-based application. A new type of component, called
CMSFlexComponent, was added to SAP Commerce Cloud 1905, which allows you to get selectors, and also includes code from our libraries in the Content Slot.
Note: For backwards compatibility, Spartacus supports the
Adding Data into the
CmsSiteContext enum was created in SAP Commerce Cloud 1905. It is a dynamic enumeration that contains the available site context. Spartacus has two site contexts: language and currency. The following is an example from
INSERT_UPDATE CmsSiteContext;code[unique=true];name[lang=$language] ;LANGUAGE;"language" ;CURRENCY;"currency"
Replacing the Homepage Preview Image
The Spartacus homepage looks different from the legacy Accelerator storefront, so the preview image has been updated accordingly.
Adding a SiteContext Slot with New Components to Each Template
SiteContext slot has been added to the header in every template in Spartacus, and two new components, the
CurrencyComponent, have been added into this
SiteContext slot. The following is an example from
INSERT_UPDATE CMSSiteContextComponent;$contentCV[unique=true];uid[unique=true];name;context(code);&componentRef ;;LanguageComponent;Site Languages;LANGUAGE;LanguageComponent ;;CurrencyComponent;Site Currencies;CURRENCY;CurrencyComponent INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];name;active;cmsComponents(uid,$contentCV) ;;SiteContextSlot;Site Context Slot;true;LanguageComponent,CurrencyComponent
CMSSiteContextComponent is a new type of component that was created in SAP Commerce Cloud 1905.
Updating the MiniCartSlot
MiniCartSlot in the
electronicsContentCatalog contains two components: the
OrderComponent and the
MiniCart. In Spartacus, the
OrderComponent is not used anymore, so it was removed from the
MiniCartSlot. The following image shows the
MiniCart component in the
Adding CMSlink Components to a New SiteLinks Slot
The Spartacus header now contains
SaleLink CMSlink components, which have been added to a new
SiteLinks slot. Because this slot has been added in the header, the new
SiteLinks slot has been added to every template. The following image shows the newly added CMSlink components:
Creating New CMS Pages
The following new CMS pages have been created with the
spartacussampledata extension also creates the necessary content slots and CMS components that are contained in these new pages.
Adding More Content to the “Not Found” Page
Along with a banner image, the “Not Found” page now also includes links and text, as shown in the following image:
Adding a SignOutLink in My Account
In the default content catalogs, the
MyAccountNavNode does not have a child node for
SignOut. To fix this in Spartacus, the
spartacussampledata extension adds a
SignOutNavNode as a child of the
MyAccountNavNode, and adds a
SignOutLink to the
Updating the Breadcrumb in Spartacus
In the default content catalogs, the
breadcrumbComponent is located in the
spartacussampledata extension moves this component from the
NavigationBarSlot to the
BottomHeaderSlot, and the
BottomHeaderSlot is also added to every template. However, to avoid having a breadcrumb for the
BottomHeaderSlot is removed from the
Updating Page Labels to Start with a Forward Slash
In Spartacus, page labels are used as the configurable URL for content pages, so these page labels need to start with a
/ forward slash. The following is an example of the update that the
spartacussampledata extension makes to every content page:
UPDATE ContentPage;$contentCV[unique=true];uid[unique=true];label ;;login;/login
Adjusting the Searchbox Component Configuration
spartacussampledata extension adjusts the searchbox component configuration as follows:
INSERT_UPDATE SearchBoxComponent;uid;minCharactersBeforeRequest;maxProducts;maxSuggestions;waitTimeBeforeRequest;$contentCV[unique=true] ;SearchBox;0;5;5;0
Making CMS Changes Related to Checkout
spartacussampledata extension makes a number of CMS changes that are related to checkout. For more information, see Extending Checkout.
Making the Product Details Page CMS-Driven
spartacussampledata extension makes the
ProductDetails template CMS-driven by adding another
ProductSummarySlot slot, which contains the following CMS components: