Magento 2: Override di.xml in custom theme
-
11-03-2021 - |
質問
I have a module in vendor/company/module
. I have created the following folder to override files.
/vendor/theme/theme-frontend-default/Company_Module
.
I am able to override files in view folder but I also want to override model and maybe di.xml
if required. Creating di.xml
in /vendor/theme/theme-frontend-default/Company_Module/etc/frontend/di.xml
does not override. Is there a different way to override di.xml or models?
解決
di.xml files and models are considered "backend" code. Themes only deal with frontend code: layout, template, css/less, javascript, images, etc.
You must create a module to accomplish those backend tasks. I usually just create a module called MageModule_ThemeHelper or something like that just so I know its sole purpose is to help my theme.