The Vue Storefront Essentials Course is now available! Learn More
Product review normalizer

Product review normalizer

The normalizeProductReview function maps SAP Review into Unified SfProductReview.


NameTypeDefault valueDescription
reviewReviewSAP Review


The SfProductReview is returned from GetProductReviews Method. If the SfProductReview structure doesn't contain the information you need for your Storefront, you can extend its logic using the defineNormalizers function. The following example demonstrates how to extend SfProductReview with a alias field.

import { normalizers as normalizersSAP, defineNormalizers } from "@vsf-enterprise/unified-api-sapcc";

const normalizers = defineNormalizers<typeof normalizersSAP>()({
  normalizeProductReview: (review) => ({
    alias: review.alias,


import { maybe } from "@shared/utils";
import { Review } from "@vsf-enterprise/sapcc-types";
import { SfProductReview } from "@vue-storefront/unified-data-model";

export function normalizeProductReview(review: Review): SfProductReview {
  return {
    id:! as string,
    title: maybe(,
    text: maybe(review.comment),
    rating: maybe(review.rating),
    reviewer: maybe(review.principal?.name),
    createdAt: new Date(!).toISOString(),