In this article, we will look into modules which can be override and use in our custom module in Shopware 6. I hope you know the directory structure of Shopware 6 plugin, if you don’t know, see here- https://docs.shopware.com/en/shopware-platform-dev-en/internals/directory-structure.
Setup :
You can create a new plugin for shopware 6. To learn creating a plugin at first. There is a link:-
The main entry point to customize the administration via plugin is main.js
file. File is placed into <plugin root>/src/Resources/administration
directory. It will automatically found by shopware 6. If you don
In main.js
file, override Vue Component using override method of an ComponentFactory
.
The first parameter is component to override and second parameter is new twig template for this component.
import template from './src/extension/sw-order-detail/sw-order-detail.html.twig';<br></code><br><code>Component.override('sw-order-detail', {<br> template,<br> });
You can add your code in main.js
file. Whatever you want to do in your module. It is same as you write in index.js
file but methods or function which is overridden, copy the same data in main.js
file as in index.js
of override component.
After that create a twig template for your plugin in following directory <plugin root>/src/Resources/administration/src/extension/sw-order-detail
.
In this case file name is sw-order-detail.html.twig
{% block sw_order_detail_content_tabs %}<br> {% parent %}</code><br> <code>{% block override_content %}<br> {# Add your code here #}<br> {% endblock %}<br>{% endblock %}
In Twig template, block sw_order_detail_content_tabs
is overridden . This block contain whole details of order detail page and you can add your custom fields.
Block override_content is custom block in here you can add your own code.
You can learn more about templates inheritance to understand how blocks in Twig work.
Now you can run the command ./psh.phar administration:build
in your Shopware root directory.
I hope It will help you. Thanks
Be the first to comment.