cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble understanding component file structure

Trouble understanding component file structure

I'm trying to understand the file structure for components in Magento2 and having some trouble puzzling through the documentation.

I'm building 2 components, a module to add the custom behavior I'd like and a theme that'll define the design for everything on the site's frontend (category, search, product, cart, checkout, etc).

 

I have my logic module in:

/vendor/MyVendorName/MyLogicModule/

 

 

Within that I have composer.json which defines the module:

{
    "name":"my-vendor-name/magento-module-logic",
    "type": "magento2-module",
    "autoload": {
        "files": [ "registration.php" ],
        "psr-4": {
            "Magento\\CatalogImportExport\\": ""
        }
    }
}

 

 

and etc/module.xml which defines the module name as

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="MyVendorName_LogicModule" setup_version="0.0.1" />
</config>

 

 

 

and registration.php which calls:

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'MyVendorName_LogicModule', __DIR__);

 

 

Does the name I provide in composer.json need to match the name I use in registration and module.xml? Or is this just used for reference in composer's internal logic while the module.xml is used internally in Magento?

 


For the theme, it seems that it can be places in serveral different locations, but I'd like it to go along side my other component at:

/vendor/MyVendorName/MyDesignTheme/

 

Within that I have composer.json which defines the module:

{
    "name":"my-vendor-name/magento-theme-my-design-frontend",
    "type": "magento2-theme",
    "autoload": {
        "files": [ "registration.php" ],
        "psr-4": {
            "Magento\\CatalogImportExport\\": ""
        }
    }
}


And registration.php calls:

ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/MyVendorName/MyDesign', __DIR__);

 

 

And that's where I get lost. Is there a file analagous to etc/module.xml that defines this as a theme?


Where do my template files go? Do I create subdirectories for each of the modules I'd like to override (e.g. /vendor/MyVendorName/MyLogicModule/Magento_Catalog) and fill those with my overridden version of template files and the layout files that define the override?

 

 

Any help would be appreciated,
-Ben