I need to modify the layout xml for another module from my Magento 2 module. In this module they use in the controller execute() method a way to add their layout xml:


I need to use the custom_module_layout.xml in my module to modify a template and block class, but it seems Magento 2 doesn't look in my module for this layout file even when I have it in the proper location and my module.xml file has set to load their module first.

Is this a Magento 2 bug or just way it does things? So I would have to add a plugin to execute() to add my own layout xml file, or is there a better way?

  • can you post your code please? – Marius Nov 12 '20 at 8:14
  • Sorry was just a dumb thing on my part, I had disabled and re-enabled the module but was checking a different layout file for a ui component. Now it's working on the original layout xml file I was trying to change. – Kevin Chavez Nov 12 '20 at 8:46

Fixed, was just an issue that I needed to disable and enable my module for the layout load order changes to take effect. Looking at app/etc/config.php it seemed the load order was ok but it actually wasn't.

Reference: Magento 2: Does Module Sequence Impact Layout Handle XML Loading Order?

So I just did:

bin/magento module:disable my_module


bin/magento module:enable my_module

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.