I have installed one custom module using composer as usually that module was installed in vendor directory is there any way to override phtml file in the same module like name but on app/code

module install path -


App path -


Is there is any best possible way to override that and use the custom template file that resides in the app/code with the same vendor module ? just like we override the module file in the custom theme.

2 Answers 2


How to override with XML

Using layout xml

<referenceBlock name="block-name">
    <action method="setTemplate">
        <argument name="template" xsi:type="string">MyCustom_Module::path/to/my/file.phtml </argument>

How to override with PLUGIN

Declare your plugin either in etc/di.xml or etc/frontend/di.xml

namespace My\Module\Plugin;

class Block
    public function beforeToHtml(\Other\Module\Block $block)

You will require to override phtml file in design in your theme


e.g for overrdie Magento paypal template file.

app/design/Vendorname/themename/Magento_Payapl/templates/yourphtml file path.

another example for third-party module installed by the composer is Magefan_Blog module

app/design/Vendorname/themename/Magefan_blog/templates/yourphtml file path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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