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

Intro to Magento 2: Let's build a Module!

Apr 21, 2017

Download

Internet

David Stillson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Intro to Magento 2: Let's build a Module!

INTRO TO MAGENTO 2LET’S BUILD A MODULE!

Page 2: Intro to Magento 2: Let'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

Page 3: Intro to Magento 2: Let's build a Module!

MAGENTO

SOME COOL FACTS:

Page 4: Intro to Magento 2: Let's build a Module!

COMPOSERINSTALLATION AND UPDATES

ARE ALL AUTOMATICALLY PULLED FROM MAGENTO’S REPO

Page 5: Intro to Magento 2: Let's build a Module!

CLIbin/magento

Page 6: Intro to Magento 2: Let's build a Module!

INTRO TO MAGENTO 2 SWAGGER IS INCLUDED!

Page 7: Intro to Magento 2: Let's build a Module!

INSTALLATION

Page 8: Intro to Magento 2: Let's build a Module!

INTRO TO MAGENTO2

INSTALLATION

Page 9: Intro to Magento 2: Let's build a Module!
Page 10: Intro to Magento 2: Let's build a Module!
Page 11: Intro to Magento 2: Let's build a Module!

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

Or…. Install into your own environment with Composer!

Page 12: Intro to Magento 2: Let's build a Module!
Page 13: Intro to Magento 2: Let's build a Module!
Page 14: Intro to Magento 2: Let's build a Module!

Admin Interface

Page 15: Intro to Magento 2: Let's build a Module!

DESIGN PATTERNS & PRINCIPLES

Page 16: Intro to Magento 2: Let's build a Module!

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.

Page 17: Intro to Magento 2: Let's build a Module!

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.

Page 18: Intro to Magento 2: Let's build a Module!

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.

Page 19: Intro to Magento 2: Let's build a Module!

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.

Page 20: Intro to Magento 2: Let's build a Module!

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

Architecture Diagram

Page 21: Intro to Magento 2: Let's build a Module!
Page 22: Intro to Magento 2: Let's build a Module!

MODULAR ARCHITECTURE!

EVERYTHING IS NOW A MODULE.

Page 23: Intro to Magento 2: Let's build a Module!
Page 24: Intro to Magento 2: Let's build a Module!

BLOCKS, TEMPLATES, & LAYOUTS

Page 25: Intro to Magento 2: Let's build a Module!

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

Page 26: Intro to Magento 2: Let's build a Module!

Layout Tree:

Page 27: Intro to Magento 2: Let's build a Module!
Page 28: Intro to Magento 2: Let's build a Module!

M2 with template hints enabled:

Page 29: Intro to Magento 2: Let's build a Module!
Page 30: Intro to Magento 2: Let's build a Module!

EXECUTION FLOW

Page 31: Intro to Magento 2: Let's build a Module!

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

Page 32: Intro to Magento 2: Let's build a Module!
Page 33: Intro to Magento 2: Let's build a Module!

INTRO TO MAGENTO 2

TOOLING

▸ PHPStorm

▸ Commerce Bug

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

▸ Magicento2

▸ http://magicento.com/

Page 34: Intro to Magento 2: Let's build a Module!

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

Page 35: Intro to Magento 2: Let's build a Module!

LET’S BUILD OUR MODULE!

Page 36: Intro to Magento 2: Let's build a Module!

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