I try to change some "view" files from a module called Amasty_MegaMenu.

I installed the module via composer. It is located in vendor\amasty\mega-menu.

So I created app/code/Amasty/MegaMenu with these files:



and app\code\Amasty\MegaMenu\etc\module.xml

<?xml version="1.0"?>
 * @author Amasty Team
 * @copyright Copyright (c) 2020 Amasty (https://www.amasty.com)
 * @package Amasty_MegaMenu

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Amasty_MegaMenu" setup_version="1.5.0">
            <module name="Amasty_Base"/>
            <module name="Magento_Cms"/>
            <module name="Magento_Theme"/>
            <module name="Magento_CatalogWidget"/>

which I have copied from the original vendor module.

Then I added the files which I want to replace




Then I executed php bin/magento setup:upgrade but I get:

Autoload error: Module 'Amasty_MegaMenu' from '/home/company/redesign.company.com/app/code/Amasty/MegaMenu' has been already defined in '/home/company/redesign.company.de/vendor/amasty/mega-menu'.

  • You don't need to create a module for that, just place it in your current theme like this : app/design/frontend/Your-theme/theme-name/Amasty_MegaMenu/web/css/source/mkcss/ammenu.css
    – PЯINCƎ
    Commented Feb 24, 2020 at 22:52

3 Answers 3


If you are just trying to change view files, then you don't need to create a new module at all. Instead you can just create them under the app/design folder to override them with your theme. For example if I wanted to override the following vendor files


We can use the following template to override web files in a module.


An example extending the amasty files onto the Magento Luma theme would be.


But to answer why are are getting the error message, Magento treats all modules in app/code and vendor as a big pool. So since you name your new module Amasty_MegaMenu it clashes with the Amasty one in vendor. So the options you would have would be.

1. Rename your module

This would be the ideal solution, generally when overriding modules I would advise to use your own Vendor prefix to show who created the override. So for example you could name the module Sam_AmastyMegaMenu.

In your etc\module.xml file you would add a dependency for the original module.

Then because we want to override stylesheets, we would need to find where they are included (layout xml / templates etc). Then override the relevant layout xml / template to use the asset from our new module.

2. Move module to app/code

This is the less ideal solution as you would have to manage the module updates manually, and editing vendor files would cause you to lose modifications during updates. But you would uninstall the module from composer composer remove amasty/mega-menu. Then download their file archive (a zip file i think) and extract that into your app/code folder


I think you remove the module name database

Please going the database and open the setup_module and remove the your module name

And after add the your files like Your app/code file path:-




And after run the php bin/magento s:up

Hope help you


  • I removed the module from setup_module but it does still not work. Same error.
    – Black
    Commented Feb 25, 2020 at 9:40
  1. Remove entry fromsetup_module table.
  2. Also if you find it's entry in app/etc/config.php , you should delete it from there as well.
  3. Now run following commands

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

chmod 777 -R var pub generate

If you sill getting error then run below command in magento root directory and check.

composer dump-autoload

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.