A third-party module uses a layout update that changes the template path for a core block from Magento_Catalog::product/view/addto/compare.phtml toMyCompany_MyModule::custom/view/addto/compare.phtml. The merchant has a customized version of this template in their custom theme. What is a consequence of this setup?

A - This setup will throw an IllegalStateException.

B - If a preference for the core block is set, the template will no longer apply.

C - If another module is installed which also customizes the same core template, the templates will be rendered sequentially.

D - If the custom module is removed, the custom template will no longer apply.

Please correct me on this which answer is correct of given 4 options i tried much R&D of it and according to C or D is the correct answer please help me to correct this.

3 Answers 3


Correct answer is D.

Ref: Magento DevDocs Override templates


I think not A: If a template cannot be found, as far as I know, the block is just not rendered.

Also probably not B: A preference on the block only leads to some weird behavior, it the theme path does not contain the Module prefix. For example if the theme path is declared as only custom/view/addto/compare.phtml, the Module part of the theme path is determined by the Namespace of the block. In this case, adding a preference to a block that changes the \Company\Module\ namespace would lead to the theme being loaded from Company_Module::custom/view/addto/compare.phtml

C (slightly different): If another module sets the template, it depends on the module loading order which one will be used. If not defined explicitly via module sequence (in /etc/module.xml of the module) I think it's determined alphabetically, where the module is used, that comes last in that order (see app/etc/config.php for the actual module loading order in your project).

And definitely D: If the module is removed (and no other module changes the path to the theme) it will be loaded from Magento_Catalog::product/view/addto/compare.phtml again.

  • so which one is correct Jan 29, 2019 at 10:17
  • that depends on your specific case, your description is very general. Based on the information you provided partly C and definitely D Jan 29, 2019 at 10:34

Simple Answer is D.

D - If the custom module is removed, the custom template will no longer apply.

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.