We are going to override the shopware 6 default file in a custom theme. To override the twig file in shopware 6 follows the below instructions.
Shopware 6 uses the Twig template for Storefront. Find the template which you want to extend in your theme. I’m overriding the “login.html.twig” file in a theme and changing the login text on the login page.
You have to find the specific twig file and override the file into a theme. Now navigate the file in a theme directory.
custom/plugins/Yourtheme/src/Resources/views/storefront/component
Now create the exact directory structure in your theme starting from the views(of the storefront) and create a template file with the same name just like the original file.
You can override the original template by overriding its blocks, but in the line of the file, you have to write the below code.
{% sw_extends ‘@Storefront/component/account/login.html.twig’ %}
Find the block in the parent twig file in which you want to make an override and add the same block in your custom twig file.
You can use the parent() function to get the original content of the block and then we can add our own content. Eg:- “component_account_login_custom_text”
After overriding the file, remember to clear the cache of your store.
Result
Please contact us at manish@bay20.com or call us at +91-8800519180 for any support related to shopware. You can also visit the Shopware development page to check the services we offer.