Magento: Difference between revisions

From Wiki RB4
Line 66: Line 66:


===Modules===
===Modules===
A Magento '''Module''' is a directory with subdirectories containing blocks, controllers, helpers, and models that are needed to create a specific store feature. It has a life cycle that allows them to be installed, deleted, or disabled. Modules typically live in the vendor directory of a Magento installation, in a directory with the following PSR-0 compliant format: vendor/<VENDOR>/<TYPE>-<MODULENAME>, where <TYPE> can be one of the following values:
A Magento '''Module''' is a directory with subdirectories containing blocks, controllers, helpers, and models that are needed to create a specific store feature. It has a life cycle that allows them to be installed, deleted, or disabled. Modules typically live in the vendor directory of a Magento installation, in a directory with the following PSR-0 compliant format: vendor/<VENDORNAME>/<TYPE>-<MODULENAME>, where <TYPE> can be one of the following values:


* module - for modules (module-customer-import-export)
* module - for modules (module-customer-import-export)
* theme - for frontend and admin themes (theme-frontend-luma or theme-adminhtml-backend)
* theme - for frontend and admin themes (theme-frontend-luma or theme-adminhtml-backend)
* language - for language packs (language-de_de)
* language - for language packs (language-de_de)
Or you can just create the app/code/<VENDORNAME>/<TYPE>-<MODULENAME> directory and the required directories within it. Inside this folder, you will find all the code related to this module, including the etc/module.xml file, which contains the name and version of the module, as well as any dependencies.


===Themes===
===Themes===

Revision as of 19:45, 15 August 2018

General

  • Magento 2 was released in 2015
  • Variants
    • Magento Open Source (before 2018 Magento Community Edition)
    • Magento Commerce (before Magento Enterprise Edition)
    • Differences see here
  • object oriented
  • uses design patterns (GoF) like GRASP, but in an individual manner
  • uses MVC with thin controller approach (Business Logic is mainly in Model or View), View is configured by layout XML
  • user groups:
    • web business user
    • system administrator
    • web API user

Technology

Coding Standards

PHP

  • PSR-1
    • each sub-word should be capitalised in both instances, with classes having an initial upper-case letter (StudlyCaps) and methods an initial lower-case letter (camelCase)
    • Class constants MUST be declared in all upper case with underscore separators
  • PSR-2

Architecture

  • layers:
    • presentation
    • service
    • domain
    • persistence

Persistence Layer

  • consists of
    • layouts
    • blocks
    • templates
    • controllers

Service Layer

  • bridges presentation and domain layer
  • provides service contracts (PHP interface, REST/SOAP API): a service contract is a set of PHP interfaces that is defined by a module. This contract comprises data interfaces and service interfaces.

Business Layer

  • implementents the business logic
  • modul communication via event observers, pluginsa and di.xml

Persistance Layer

  • implements CRUD (create, read, update, delete) requests
  • there are 3 types of classes:
    • model classes: don't contain any code for communicating with the DB
    • resource classes: read and write to the DB
    • collection classes: array of individual model instances which implement IteratorAggregate and Countable
  • models and resources are often seen as an unified thing called model
  • there are simple resource model and Entity-Attribute-Value (EAV) resource model

Modules

A Magento Module is a directory with subdirectories containing blocks, controllers, helpers, and models that are needed to create a specific store feature. It has a life cycle that allows them to be installed, deleted, or disabled. Modules typically live in the vendor directory of a Magento installation, in a directory with the following PSR-0 compliant format: vendor/<VENDORNAME>/<TYPE>-<MODULENAME>, where <TYPE> can be one of the following values:

  • module - for modules (module-customer-import-export)
  • theme - for frontend and admin themes (theme-frontend-luma or theme-adminhtml-backend)
  • language - for language packs (language-de_de)

Or you can just create the app/code/<VENDORNAME>/<TYPE>-<MODULENAME> directory and the required directories within it. Inside this folder, you will find all the code related to this module, including the etc/module.xml file, which contains the name and version of the module, as well as any dependencies.

Themes

Modules and themes are the units of customization in Magento. Themes strongly influence user experience and storefront appearance.

Caching

  • located in /var/ directory

Code Generation

  • Factory, Proxy and Interceptor classes are generated and stored in /var/generation/

Directory Structure

  • /var/generation: contains only? generated files
  • /var/?: cached infos

Magento Marketplace

  • UweHeuerAccessKey
    • Public Key: 6f7df3e4e393b84da74c41937990b227
    • Private Key: a39505396b6112f47c43aa8c565cad8b

Installation

Sources