Custom fields are a basic feature of Shopware 6 and allow you to extend products, categories or manufacturers individually. With custom fields you can flexibly store additional information and output it in the storefront when needed.
Because neither Shopware nor ThemeWare® can know in which file or in which Twig block your individual custom field should be integrated, individual custom fields have to be embedded into the storefront manually.
This works either with a CMS element in a Shopping Experience layout or with an individual template customisation:
CMS element
- Advantages
- very easy to implement
- Disadvantages
- only available from Shopware 6.6.9
- it is not possible to check whether a custom field is empty
Template customisation
- Advantages
- already available before Shopware 6.6.9
- it is possible to check whether a custom field is empty
- Disadvantages
- quite complex to implement
In this tutorial we explain how you can output custom fields in the storefront with a template customisation.
Note: How to output a custom field in the storefront with a CMS element you will discover in the tutorial Show custom fields in Shopping Experiences.
Output a custom field with a template customisation
In the following step-by-step guide we embed the individual custom field "Safety notice" on the product detail page (PDP) in the storefront, using our free ThemeWare® Customizing Plugin.
Tip: How to create an individual custom field you will discover in the tutorial Custom Fields
Note: You can find more information about template customisations in the section Individual customizations.
Attention: Never edit original files of Shopware or of extensions (plugins, apps or themes)!
Template customisation with the ThemeWare® Customizing Plugin
1) Create the template file
The product description is loaded into the storefront via the template file description.html (see GitHub).
So create the file description.html.twig in the following folder of the Customizing Plugin:
src/Resources/views/storefront/component/product/
Note: We recommend working locally and uploading the files once you are finished. This way you directly have a "backup copy" of your customisations.
2) Extend the original template
Now extend the original file of Shopware as follows:
{% sw_extends '@Storefront/storefront/component/product/description.html.twig' %}
3) Inherit the Twig block
The description is located in the Twig block component_product_description_content. We now inherit the block as follows:
{% sw_extends '@Storefront/storefront/component/product/description.html.twig' %}
{# GPSR: output the custom field "Safety notice" #}
{% block component_product_description_content %}
{# Default block #}
{{ parent() }}
{% endblock %}
Tip: Add descriptive comments to your customisations. They make it easier for you to find your way around later.
4) Insert the custom field
Now insert the custom field (e.g. custom_gpsr_sicherheitshinweis) after the actual content of the Twig block (⇒ {{ parent() }}):
{% sw_extends '@Storefront/storefront/component/product/description.html.twig' %}
{# GPSR: add the custom field "Safety notice" #}
{% block component_product_description_content %}
{# Default block #}
{{ parent() }}
{# Output the custom field "Safety notice" #}
{{ page.product.customFields.custom_gpsr_sicherheitshinweis|raw }}
{% endblock %}
Note: The addition |raw is necessary because we created a custom field that supports HTML. As a result, the HTML code is not simply output but interpreted, and your text is formatted accordingly.
Optional: You can also combine the integration with an if that checks whether the custom field is filled at all, and add a headline:
{% sw_extends '@Storefront/storefront/component/product/description.html.twig' %}
{# GPSR: add the custom field "Safety notice" #}
{% block component_product_description_content %}
{# Default block #}
{{ parent() }}
{# Output the custom field "Safety notice" including a headline (if filled) #}
{% if page.product.translated.customFields.custom_gpsr_sicherheitshinweis %}
<h3>Safety notice:</h3>
<div>{{ page.product.translated.customFields.custom_gpsr_sicherheitshinweis|raw }}</div>
{% endif %}
{% endblock %}
Tip: For multilingual storefronts it makes sense to use a snippet for the headline.
Note: You can output a custom field of a manufacturer with the following syntax:{{ page.product.manufacturer.customFields.YOURCUSTOMFIELD|raw }}
5) Upload the template file
Now upload the new template file to your web server into the directory:
custom/plugins/TcinnCustomizing/src/Resources/views/storefront/component/product
6) Clear the cache
Finally, clear the Shopware cache and your browser cache once so that the change is displayed correctly in the storefront.
Example

Custom field in the description
Further information
You can find more information about custom fields in the following article:
Custom Fields