Leon Schwanitz
Leon Schwanitz

Reputation: 283

Shopware 6 App - Override .../storefront/page/product-detail/buy-widget.html.twig

when i try to override the buy-widget.html.twig file. Shopware does nothing. Only the index override works. But not the sub file. My code is:

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


{% block page_product_detail_buy_form %}
    <h1 style="background: green;">Test</h1>
{% endblock %}

Why does this not work?

Upvotes: 0

Views: 316

Answers (2)

j_elfering
j_elfering

Reputation: 3190

If you APP_ENV is set to "dev", the templates changes should be reloaded live when you make changes to the files or add new template files etc.

Otherwise an reinstall or update of your app is necessary as the templates are only reloaded for apps on install and update in prod environments.

Upvotes: 4

aragon999
aragon999

Reputation: 126

As one comment stated when changing or adding a template, the cache has to be cleared. When developing, preferably use APP_ENV=dev in your .env file, to enable the development mode.

The dev mode adds the developer toolbar (at the bottom of the page), in the "TWIG" panel all rendered templates, including their inheritance, are listed.

Also note that for the buy-widget.html.twig template there are two occurrences, once in the page/product-detail/buy-widget.html.twig, which is used when no layout is assigned to the product and once in component/buy-widget/buy-widget.html.twig, which is used in combination with product layouts.

Upvotes: 7

Related Questions