Value Formatters

Value Formatters are a set of functions that format a value based on its' context type and value into a presentable state.

You don’t have to do anything, these formatters are set by default. We want to explain the expected behaviour and its' options.

AttributeFormatter supports Required context Optional context Description
Base64File pim_catalog_image Base64Encodes your images
Boolean pim_catalog_boolean locale returns a Yes/No
BooleanLabels pim_catalog_boolean locale, boolean-label-format: true returns the attribute label if yes
Metric pim_catalog_metric map
PriceCollection pim_catalog_price_collection currency map returns the selected currency and formats the amount.
TransformValue all transform

Here are a couple of examples.

Metric

{
    'storage': [{
        locale: null,
        scope: null,
        data: {
            'unit': GIGABYTE,
            'amount': 64.0000
    }]
}
{{ normalize(``'storage', {'map': [GIGABYTE: GB]}``) }}
becomes : 64 GB
{{ normalize(``'storage', {'map': [GIGABYTE: GB], 'format': '%unit%%amount%'}``) }}
becomes: 64GB

Currency

{

    'retail_price': [{
        locale: null,
        scope: null,
        data: [{
            'amount': 899.00,
            'currency': EUR
     }]

...

}
{{ normalize(``'storage', {'currency': EUR, 'map': [EUR: €]}``) }}
becomes : 899 €

Simple Value Formatting

Simple values like text fields sometimes need a different formatting.

You can manipulate the Presenter by supplying a format directive.

A simple value is presented as ‘%value%’ for replacement.

For example add more context to a value that requires this needed context.

Text

{

    'megapixel': [{
        locale: null,
        scope: null,
        data: 12

...

}
{{ normalize(``'megapixel', {'format': '%value%MP'}``) }}
becomes : 12MP
{{ normalize(``'megapixel', {'format': '%value% megapixel'}``) }}
becomes : 12 megapixel

TransformValueFormatter

Product data
{

    'sku': [{
        locale: null,
        scope: null,
        data: 12345

...

}
Translation data

{

   'domain': {
        nl_BE: "nl.domain.be",
        fr_BE: "fr.domain.be"

....
}
Examples
{{ normalize(``'sku', {'transform': {'func':'link', 'src':'https://%domain%/product/%sku%', 'code':'sku','translations':'domain'}}``) }}
becomes : a clickable link inside the PDF, https://nl.domain.be/product/12345
{{ normalize(``'sku', {‘transform’: “{‘func’:‘link’, ‘src’:‘https://shop.project.eu/project/%sku%', ‘code’: ‘sku’}"}}``) }}
becomes : a clickable link inside the PDF, https://shop.project.eu/product/12345

MultiValuePresenter

This value presenter acts on array values that need more formatting.

PriceCollection and metrics needs this presenter to format a presentable string

A value collection like a multi select will presents values with a correct separator.

Product data (Multi Select Values)
{

    'color': [{
        locale: null,
        scope: null,
        data: yellow

}, {

        locale: null,
        scope: null,
        data: red

...

}
Examples
{{ normalize(``'color', {'value-separator': ', '}``) }}
becomes : yellow, red