personalizationsmarteditcontainerModule
Personalization Toolbar Menu Items
The FeatureService allows you to add additional items to the toolbar menu, contextual menu, or register any additional functionality.
- displaying existing customizations and variations (target groups) on the storefront (only one target group per customization is allowed)
- customization/variation management
For further information, see Extending the Page Tool Menu and Gateway Factory.
Displaying Existing Customizations and Variations
- add the customizations from the library,
- display the customizations and variations that affect the page that is currently being previewed,
- filter the results according to their status (for example: ENABLED, DISABLED or ALL).
For instructions on displaying existing customizations on the storefront see: View Customizations.
Customizations and Variations Management
- creating a customization with variations.
- editing an existing customization.
The modal content is presented in two tabs (ui.bootstrap.tabs implementation). Depending on which tab is selected, the NEXT_BUTTON is switched to a CONFIRM_BUTTON (or the other way around).
Each tab implements its own isDirty and isValid functionality.
Based on the information from a selected tab, the proper watcher enables/disables confirm/next button accordingly.
Creating Complex Segment Expressions
Segment expressions are built using multi-segment-view directive, available in the personalizationsmarteditSegmentViewModule.
The multi-segment-view represents both SegmentTriggerData and ExpressionTriggerData objects from the backend system. The personalizationsmarteditTriggerService was created as part of personalizationsmarteditManagerModule to accommodate them. If an expression is simple (just one top-level group, it doesn't contain subgroups) it will be stored as SegmentTriggerData, otherwise it will be stored as ExpressionTriggerData.
The personalizationsmarteditTriggerService also handles the DefaultTriggerData. It is a special case of trigger that applies to all users (may even be anonymous). Only one of DefaultTriggerData/SegmentTriggerData/ExpressionTriggerData can be related to a selected variation. Attempt to create another one will fail.
Reloading Storefront based on Selected Customization and Variations
Experience Storefront Rendering
Variations (or customizations which group variations) fully define the experience using linked actions. Such actions may define how the storefront should look (for instance by displaying different banners for a user who falls into a specific segment).
On the side of the Accelerator everything is handled by the personalizationcms extension which, with the use of DefaultCxCmsContainerStrategy, calculates the components to display for a logged user. The Personalizationcms extends also the preview ticket data model with variations, then the CxVariationPreviewStrategy based on extended data model sets action-based session attributes and the actual component calculation is being done transparently with the DefaultCxCmsContainerStrategy.
For details see: personalizationcms Extension.
Updating Preview Ticket with Selected Customizations/Variations
//First we call GET for existing ticket
personalizationsmarteditRestService.getPreviewTicket().then(function successCallback(previewTicket) {
//then we set selected variations for preview ticket
previewTicket.variations = selectedVariationsCodes;
//and then we call PUT for updating existing preview ticket
personalizationsmarteditRestService.updatePreviewTicket(previewTicket).then(function successCallback(response) {
return sharedDataService.get("preview").then(function successCallback(preview) {
iFrameManager.loadPreview(preview.resourcePath, preview.previewTicketId);
});
}, function errorCallback(response) {
personalizationsmarteditErrorHandler.sendError($filter('translate')('personalization.error.updatingpreviewticket'));
});
//...
});
Refreshing the Preview Ticket
To preview a selected storefront using SmartEdit, a previewwebservices rest POST is called on the preview resource. The previewwebservices extension, on the other hand, is using the existing cms2 functionality (DefaultCMSPreviewTicketService to be precise) to create a preview ticket. The mentioned service, apart from preview ticket creation, instantiates a task runner, which after 15 minutes removes the created preview ticket.
previewService.updatePreviewTicket = function(variations) {
var deferred = $q.defer();
var selectedVariationsCodes = personalizationsmarteditUtils.getVariationCodesForPreviewTicket(variations);
return personalizationsmarteditRestService.getPreviewTicket().then(function successCallback(previewTicket) {
previewTicket.variations = selectedVariationsCodes;
return personalizationsmarteditRestService.updatePreviewTicket(previewTicket);
}, function errorCallback(response) {
if (response.status === 404) {
//preview ticket not found - let's try to create a new one with the same parameters
return createPreviewTicket(selectedVariationsCodes);
} else {
personalizationsmarteditErrorHandler.sendError($filter('translate')('personalization.error.gettingpreviewticket'));
return deferred.reject(response);
}
});
};
var createPreviewTicket = function(variationsForPreview) {
var experience = personalizationsmarteditContextService.seExperienceData;
var configuration = personalizationsmarteditContextService.seConfigurationData;
var deferred = $q.defer();
var resourcePath = configuration.domain + experience.siteDescriptor.previewUrl;
var previewTicket = {
catalog: experience.catalogDescriptor.catalogId,
catalogVersion: experience.catalogDescriptor.catalogVersion,
language: experience.languageDescriptor.isocode,
resourcePath: resourcePath,
variations: variationsForPreview
};
return personalizationsmarteditRestService.createPreviewTicket(previewTicket).then(function successCallback(response) {
storePreviewTicketData(response.resourcePath, response.ticketId);
personalizationsmarteditErrorHandler.sendInformation($filter('translate')('personalization.info.newpreviewticketcreated'));
return deferred.resolve(response);
}, function errorCallback(response) {
personalizationsmarteditErrorHandler.sendError($filter('translate')('personalization.error.creatingpreviewticket'));
return deferred.reject(response);
});
};
Useful links
Combined View
The personalizationsmarteditCombinedViewModule module contains services and controllers used to support the combined view in container application. A user can select any number of target groups and customizations from the list to display them on the storefront, and the service will automatically assign the colors and letters to selected items.
Once the preview ticket is updated, this information is presented on page (as borders surrounding the components). The decorator highlights the components that are customized as well as renders a preview of the current customizations for comparison. As a result, the user sees how the customizations affect the page.