Skip to content

CustomField label loading in storefront

You are viewing an outdated version of the documentation.
Click here to switch to the stable version (v6.6), or use the version switcher on the left to navigate between versions.

CustomField label loading in storefront

INFO

This document represents an architecture decision record (ADR) and has been mirrored from the ADR section in our Shopware 6 repository. You can find the original version here

Context

We want to provide the labels of custom fields in the storefront to third party developers. On one hand we could add the labels to every loaded entity, but this will cause a heavy leak of performance and the labels are often not used in the template.

Decision

We implemented a subscriber, which listen on the custom_field.written event to add also snippets to all snippet sets with the given label translations of the custom field. The translationKey of the snippets are prefixed with customFields., followed by the technical name of the custom field. Thus the snippets can be used in the storefront.

Consequences

Inserting a custom field always creates new snippet with the given label translations.