Search code examples
shopwareshopware6

Display product custom field in listing page in shopware 6?


I created a custom field and assigned it to the products and I want to display that custom field value on the listing page. On the description.html.twig page, I add this below variable and the value is showing on the detail page.

{{ page.product.translated.customFields.custom_events_dates }}

The same variable I placed on the box-standard.html.twig, but the value is not showing.

{% sw_extends '@Storefront/storefront/component/product/card/box-standard.html.twig' %}

{% block component_product_box_info %}
    {{ parent() }}

    <div class="test">
        <p>{{ page.product.translated.customFields.custom_events_dates }}</p>
    </div>    
{% endblock %}

How can I display the custom field value on the listing page?


Solution

  • You need to use product.translated without the page. The page object only contains the product data on a product detail page, on listing pages it is not set.