Magento 2 Module load Last order position Sequence

Sometimes you want to load a Module at the end of the sort order. In Magento 1 this could be done by changing the Vendor and/or Module name for the alphabetical order.

In Magento 2 you have to do a little more to load you module at the end of the sort order. Create a simple plugin on `Magento\Framework\Module\ModuleList\Loader` to change the sort order.

Example Module can be found in Mage2Gen

Example of how you can create this simple Plugin with just 2 files.

Create or Update the global di.xml with the following Plugin:

<?xml version="1.0" ?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<type name="Magento\Framework\Module\ModuleList\Loader">
		<plugin disabled="false" name="Vendor_Module_Plugin_Magento_Framework_Module_ModuleList_Loader" sortOrder="10" type="Vendor\Module\Plugin\Magento\Framework\Module\ModuleList\Loader"/>

Create the Plugin Class


namespace Vendor\Module\Plugin\Magento\Framework\Module\ModuleList;

class Loader

    public function afterLoad(
        \Magento\Framework\Module\ModuleList\Loader $subject,
    ) {
        if (!isset($result['Vendor_Module'])){
            return $result;
        $baseConfigModule = $result['Vendor_Module'];
        $result['Vendor_Module'] = $baseConfigModule;
        return $result;