3

I have two plugins:

  1. XYZ Plugin that is inheriting the Shopware base template/block and overriding it.
  2. ABC Plugin which I want to inherit XYZ overridden template/block and override it.

How can I do this in Shopware 6?

XYZ plugin code in tabs.html.twig file:

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

{% block page_product_detail_tabs_inner %}
    <div class="detail-accordion" id="accordion">
        {% block page_product_detail_accordion_description %}
            <div class="card card-accordion card-accordion-description">
                {% block page_product_detail_accordion_description_header %}
                    {# My custom logic #}
                {% endblock %}
            </div>
        {% endblock %}
    </div>
{% endblock %}

ABC plugin code in tabs.html.twig file:

{% sw_extends '../../../../../../../XYZ/src/Resources/views/storefront/page/product-detail/tabs.html.twig' %}

{% block page_product_detail_tabs_inner %}
    {{ parent() }}
    <div class="detail-accordion" id="accordion">
        {% block page_product_detail_accordion_description %}
            <div class="card card-accordion card-accordion-description">
                {% block page_product_detail_accordion_description_header %}
                    {# My new custom logic to append #}
                {% endblock %}
            </div>
        {% endblock %}
    </div>
{% endblock %}

Unfortunately, this code is not working.

1
  • Would be nice if you would accept my answer. Thanks.
    – Roman
    Sep 27, 2021 at 17:37

1 Answer 1

4
{% sw_extends '../../../../../../../XYZ/src/Resources/views/storefront/page/product-detail/tabs.html.twig' %}

this is wrong.

You have to extend @Storefront in both cases and make sure that you your plugins are loaded in the right sequence. So if you first load your plugin ABC then XYZ is automatically able to extend the template of ABC.

Updated answer Plugins are getting loaded in the order of the installation date (currently v6.4).

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.