Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building magento modules

I'm just about to start building my first magento module but I can't find any literature on the difference between the local and community folder in core. I've noticed that some people build their modules in local and others in community, what is the difference and why should I use one or the other?

Thanks

like image 259
Tom Avatar asked Jun 17 '09 07:06

Tom


People also ask

What are modules in magento?

What is a Magento module? A module is a logical group – that is, a directory containing blocks, controllers, helpers, models – that are related to a specific business feature. In keeping with Magento's commitment to optimal modularity, a module encapsulates one feature and has minimal dependencies on other modules.

What is module development in magento?

The module is basically a structural element of Magento 2. A whole new system is built upon modules in Magento 2. The first step towards building a customized eCommerce store is building a module. In today's tutorial, we will help you with a guide to create a custom module.

Where are all the core modules located in magento 2?

On the magneto 2 root folder where app is located look for vendor folder inside it look for magento folder. This is where all the core modules are. If you're not seeing vendor folder you may want to do a composer install.


1 Answers

You'll want to develop out of local. The community folder is/was intended to be the place where you'd put modules that you downloaded or bought from the Magento Marketplace. It's my understanding that the use of this folder is being phased out, and it's Varian's recommendation that all modules be placed in the local folder, even those downloaded from the marketplace.

From a system point of view, the only difference is the community folder is searched after the core folder, but before the local folder. Checkout this path setup in app/Mage.php

$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';

$app_path = implode(PS, $paths);

set_include_path($app_path . PS . Mage::registry('original_include_path'));

So, if you have two files

app/code/community/Companyname/Models/Foo.php
app/code/local/Companyname/Models/Foo.php

Magento will use the one in the community folder first.

like image 98
Alan Storm Avatar answered Oct 18 '22 17:10

Alan Storm