Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Contents

Core concepts

The Magento documentation and code keep using the same words: store view, area, module, theme, mode. The following lessons are hard to read without them, so they are explained up front. There is almost no code here — only the meaning.

Website, store, store view

One Magento installation can serve several shops. Three levels exist for that:

LevelIn codeWhat differs
WebsitewebsiteDomain, prices, customers, payment methods
Storestore (group)The root catalog category
Store viewstore viewLanguage and design

Example: a company sells clothes on example.com and electronics on tech.example.com — these are two websites. The clothes website has an English and a German version — these are two store views.

Right after installation there is one item of each level. They are managed in the admin panel: Stores → All Stores.

These levels matter to a developer: a module setting or a product name can be set separately for each store view. In code the current store view comes from Magento\Store\Model\StoreManagerInterface.

Areas

An area is a part of the application with its own configuration and pages. The same module can behave differently in each of them.

AreaWhat it is
frontendThe storefront a customer sees
adminhtmlThe admin panel
webapi_restThe REST API
graphqlThe GraphQL API
crontabScheduled jobs

The area is visible in file paths. Configuration from etc/frontend/routes.xml applies only to the storefront, from etc/adminhtml/routes.xml only to the admin panel, and a file directly in etc applies everywhere. Storefront templates live in view/frontend, admin templates in view/adminhtml.

Module

A module is a folder with code and configuration that solves one task: the catalog, the cart, reviews. A module name consists of a vendor and a name: Magento_Catalog, Acme_Hello. A module can be enabled and disabled with a command.

Theme

A theme is responsible for the look: templates, styles, images. Two storefront themes are shipped — Magento/blank and Magento/luma. Your own theme inherits from one of them and changes only the files it needs.

Application modes

ModeWhat it is for
defaultActive after installation; suitable only for the first run
developerDevelopment: errors on screen, files are built on the fly
productionA live server: everything is built in advance, errors go only to the log

The current mode is shown by a command:

bin/magento deploy:mode:show

It prints a line like Current application mode: default.

Common mistake

The words "store" and "store view" are easy to mix up: in code store usually means the store view, not the group. For example, the default store code and the ScopeInterface::SCOPE_STORE constant refer to the store view level. When the documentation says "store ID", it almost always means the store view number.

Thanks for reading!

Donate to the site — we work hard for you.