0

I have a custom module installed via composer and the path is vendor/company/module/src/registration.php.

I want to override some of these files like vendor/company/module/src/view/template/frontend/main.phtml but no path I tried worked:

app/code/Company/Module/src/view/template/frontend/main.phtml
app/code/Company/Module/view/template/frontend/main.phtml
app/design/frontend/package/theme/Company_Module/src/view/template/frontend/main.phtml
app/design/frontend/package/theme/Company_Module/view/template/frontend/main.phtml

I hope there is an easy way to do it and you don't have to create a separate module and extend.

  • You can override by using theme as you mentioned , is there any issue using themes. – Krishna ijjada Sep 22 '16 at 13:21
  • @krishnaijjadaati95Dev yes, it doesn't get parsed, inserted die() or incorrect php syntax. – Claudiu Creanga Sep 22 '16 at 13:24
  • @krishnaijjadaati95Dev deleted var folder and flushed cache – Claudiu Creanga Sep 22 '16 at 13:24
  • @ Claudiu Creanga first test whether the module is working or not, then you can migrate the templates into theme – Krishna ijjada Sep 22 '16 at 13:27
  • @krishnaijjadaati95Dev the module is working properly. if I go to website.com/module-url it is showing up properly. if I edit main.phtml in vendor the change is being picked up, but not if I edit ../theme/.. – Claudiu Creanga Sep 22 '16 at 13:29
2

Copy templates folder from

template/frontend/main.phtml

Keep your code in

app/design/frontend/package/theme/Company_Module/template/frontend/main.phtml 

What i have tried Taken the code from

\vendor\magento\module-customer\view\frontend\templates\form\login.phtml

And placed

\vendor\magento\theme-frontend-luma\Magento_Customer\templates\form\login.phtml

Working as expected.

  • yes, disregarded view/frontend and it worked. thanks! – Claudiu Creanga Sep 22 '16 at 13:46
  • 1
    and I guess if I want to override Block/Phpfile.php i will have to extend – Claudiu Creanga Sep 22 '16 at 13:50
  • it makes sense though so that composer can update it properly – Claudiu Creanga Sep 22 '16 at 13:51
  • Yes, as well as you know if you want to override only few functions use PLUGIN, or entire class use preference by extending core class. – Krishna ijjada Sep 22 '16 at 13:53

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.