Search code examples
shopware6shopware6-app

Unable to load template in theme app in production environment


I have a problem with our theme plugin (app based). We have extended the product with several custom fields (rte). When they are filled, they will displayed as separate tabs on the detail page.

File/Folder Structure

  • views/abettercms/page/product-detail/tab-one.html.twig
  • views/storefront/page/product-detail/tabs.html.twig

Extended block in views/storefront/page/product-detail/tabs.html.twig

{% sw_extends '@Storefront/storefront/page/product-detail/tabs.html.twig' %}
...
{% block page_product_detail_tabs_content_description %}
    {{ parent() }}

    {% if page.product.customFields and page.product.customFields.areanet_standardtheme_products_tab_1 %}
        <div class="tab-pane fade show"
                id="tab-one-pane"
                role="tabpanel"
                aria-labelledby="tab-one">
            {% sw_include '@AreanetStandardtheme64/abettercms/page/product-detail/tab-one.html.twig' %}
        </div>
    {% endif %}
...
{% endblock %}

In dev-mode it's working like expected and the additional tab is showing. But in prod-mode a exception is throwing:

Uncaught PHP Exception Twig\Error\LoaderError: 
"Unable to load template "abettercms/page/product-detail/tab-one.html.twig". 
(Looked into: AreanetStandardtheme64, SwagPayPal, Framework, Administration,  Storefront) 
in "@AreanetStandardtheme64/storefront/page/product-detail/tabs.html.twig" at line xyz"

Tested in 6.4.0.18 (detail page is not displayed => error) and 6.4.0.20 (detail page is displayed without additional tab).


Solution

  • You have to move the custom template folder from "views/abettercms/..." to "views/storefront/abettercms/..." - then the templates will be synced to the database.

    {% sw_include '@AreanetStandardtheme64/storefront/abettercms/page/product-detail/tab-one.html.twig' %}
    

    Templates outside "views/storefront" are not working in prod mode.