Vue Storefront is now Alokai! Learn More
Customer normalizer

Customer normalizer

The normalizeCustomer function is used to map a Magento Customer into the unified SfCustomer data model.


NameTypeDefault valueDescription
contextNormalizerContextcontext needed for the normalizer
customerCustomerMagento Customer


The SfCustomer model is returned from Unified Methods such as RegisterCustomer, LoginCustomer and GetCustomer. If the SfCustomer structure doesn't contain the information you need for your Storefront, you can extend its logic using the addCustomFields API. The following example demonstrates how to extend SfCustomer with a isSubscribed field.

export const unifiedApiExtension = createUnifiedExtension({
  normalizers: {
    addCustomFields: [
        normalizeCustomer: (context, customer) => ({
          isSubscribed: customer.is_subscribed,
  config: {


import { defineNormalizer } from "../defineNormalizer";

export const normalizeCustomer = defineNormalizer.normalizeCustomer((context, customer) => {
  if (!customer.firstname || !customer.lastname || ! {
    throw new Error("Customer must have an id, firstName, lastName and email");

  return {
    firstName: customer.firstname,
    lastName: customer.lastname,