Vue Storefront is now Alokai! Learn More
Money normalizer

Money normalizer

The normalizeMoney function maps Magento Money into Unified SfMoney.


NameTypeDefault valueDescription
contextNormalizerContextcontext needed for the normalizer
moneyMoneyMagento money


The SfMoney is returned as a part of multiple models, as for example SfProduct, SfProductCatalogItem, and SfCart. If you want to change the global attributes representation, you should override all root normalizers, so for example normalizeCart, normalizeProduct etc. If you want to extend the SfMoney with custom fields, you should use the addCustomFields API.


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

export const normalizeMoney = defineNormalizer.normalizeMoney((context, price) => {
  const amount = price.value ?? 0;
  return {
    currency: price.currency as string,
    precisionAmount: amount.toFixed(2),