intro to magento 2: let's build a module!

36
INTRO TO MAGENTO 2 LET’S BUILD A MODULE!

Upload: david-stillson

Post on 21-Apr-2017

85 views

Category:

Internet


5 download

TRANSCRIPT

INTRO TO MAGENTO 2LET’S BUILD A MODULE!

INTRO TO MAGENTO 2

WHAT IS MAGENTO?

▸ Magento is an Open Source E-commerce platform that is available in two editions

▸ Community - Free to use, somewhat limited feature set

▸ Enterprise - Licensed on a sales volume basis, has more advanced features out of the box

▸ Both editions are completely extendable/modify-able

MAGENTO

SOME COOL FACTS:

COMPOSERINSTALLATION AND UPDATES

ARE ALL AUTOMATICALLY PULLED FROM MAGENTO’S REPO

CLIbin/magento

INTRO TO MAGENTO 2 SWAGGER IS INCLUDED!

INSTALLATION

INTRO TO MAGENTO2

INSTALLATION

Source: http://devdocs.magento.com/guides/v2.1/install-gde/prereq/integrator_install_ce.html

Or…. Install into your own environment with Composer!

Admin Interface

DESIGN PATTERNS & PRINCIPLES

INTRO TO MAGENTO 2

OUT WITH THE MVC, IN WITH THE MVVM!

▸ Model - handles all CRUD operations using Resource Models and Collections

▸ View - template files that interact with a View Model ONLY

▸ View Model - A block object that will do any programmatic reading of the CRUD models, request objects, external systems, etc.

INTRO TO MAGENTO 2

SOLID PRINCIPLES▸ S - Single Responsibility Principle

▸ A class should have one, and only one, reason to change.

▸ O - Open Closed Principle

▸ You should be able to extend a classes behavior, without modifying it.

▸ L - Liskov Substitution Principle

▸ Derived classes must be substitutable for their base classes.

▸ I - Interface Segregation Principle

▸ Make fine grained interfaces that are client specific.

▸ D - Dependency Inversion Principle

▸ Depend on abstractions, not on concretions.

INTRO TO MAGENTO 2

DEPENDENCY INJECTION PRINCIPLE

▸ Magento 2 uses dependency injection as an alternative to the Magento 1.x Mage class. Dependency injection is the concept of the external environment injecting dependencies for an object instead of that object manually creating them internally.

INTRO TO MAGENTO 2

DEPENDENCY INVERSION PRINCIPLE

▸ a coding principle that stipulates you use abstractions to reduce code dependencies. This means that high level classes should use the interface of a low level class instead of working with it directly.

▸ The di.xml file maps an interface dependency to a preferred implementation class.

Source: http://devdocs.magento.com/guides/v2.1/architecture/archi_perspectives/arch_diagrams.html

Architecture Diagram

MODULAR ARCHITECTURE!

EVERYTHING IS NOW A MODULE.

BLOCKS, TEMPLATES, & LAYOUTS

What does M2’s layout structure look like anyway?

Containers Blocks/Templates

Source: http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/layouts/layout-overview.html

Layout Tree:

M2 with template hints enabled:

EXECUTION FLOW

EXECUTION FLOW

▸ Index.php

▸ Bootstrap

▸ Bootstrap::run()

▸ App

▸ App::launch()

▸ Routing

▸ FrontController::dispatch()

▸ Router::match()

▸ Controller Processing

▸ Controller::execute()

▸ Rendering

▸ View::loadLayout()

▸ View::renderLayout()

▸ Flushing Output

▸ Response::sendResponse()

▸ Four Steps

▸ Index.php calls bootstrap

▸ Bootstrap finds and calls controller

▸ Response is loaded and rendered

▸ Response is sent to response object

INTRO TO MAGENTO 2

TOOLING

▸ PHPStorm

▸ Commerce Bug

▸ https://store.pulsestorm.net/products/commerce-bug-3

▸ Magicento2

▸ http://magicento.com/

FURTHER STUDY AND RESOURCES

▸ Magento DevDocs

▸ http://devdocs.magento.com/

▸ Magento Code Samples

▸ https://github.com/magento/magento2-samples

▸ Alan Storm’s Blog

▸ http://alanstorm.com/

▸ Alan Kent’s Blog

▸ https://alankent.me/

▸ Twitter Hashtag

▸ #realmagento

LET’S BUILD OUR MODULE!

http://github.com/davidstillson/magento2-PricePerMonth