How to Show Custom Field Data in the Storefront in Shopware 6?

Custom Field Data in Shopware 6

Custom fields in shopware help you to show the additional data for products. For example, I am going to extend description.html.twig file in the theme.

The description.html.twig file is located under or you can create similar path to extend the file.

/custom/plugins/YourTheme/src/Resources/views/storefront/page/product-details/

Add the below code to extend the description.

{% sw_extends '@Storefront/storefront/page/product-detail/description.html.twig' %}

It is necessary to include the original content of the block on the description.html.twig file. Block name

 page_product_detail_description_content_text

This is possible using the

{% block page_product_detail_description_content_text %}

After adding the block we need to add the parent() function.

{{ parent() }}

And for the integration of the custom field.

{{ page.product.translated.customFields.technischer_name_customfield }}

The complete code in the description.html.twig file is

{% sw_extends '@Storefront/storefront/page/product-detail/description.html.twig' %}

{% block page_product_detail_description_content_text %}
    {{ parent() }}
    {{ page.product.translated.customFields.technical_name_customfield }}
{% endblock %}

You can find the technical name of the custom field in the settings.

Settings > System > Custom Field

You have to edit the custom field and the technical name starts with custom_

Please contact us at manish@bay20.com or call us at +91-8800519180 for any support related to shopware. You can also visit the Shopware development page to check the services we offer.