magento 2 creating a custom module fluid digitalmagento 2 creating a custom module matt edwards...
TRANSCRIPT
![Page 1: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/1.jpg)
fluid-digital.com @fluid_digital
Magento Ecommerce Agency
Magento2CreatingACustomModule
MattEdwardsTechnicalDirectorFluidDigital
![Page 2: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/2.jpg)
@fluid_digitalfluid-digital.com
Magento1vsMagento2
ModuleFileStructure
![Page 3: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/3.jpg)
@fluid_digitalfluid-digital.com
CreatinganewModule
Moduledirectory:app/code/Company/ModuleName
![Page 4: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/4.jpg)
@fluid_digitalfluid-digital.com
RegisterYourModule
Registeryourmodule:registration.php
![Page 5: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/5.jpg)
@fluid_digitalfluid-digital.com
StartAddingInRequiredDirectories
![Page 6: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/6.jpg)
@fluid_digitalfluid-digital.com
Addetc/module.xml
ModuleName:Fluid_BlogVersionNumber:1.0.2
![Page 7: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/7.jpg)
@fluid_digitalfluid-digital.com
SetupandUpgradeScripts
Setup/InstallSchema.php - initialmodulesetupscriptSetup/UpgradeSchema.php – usedforanymoduleupgrades
![Page 8: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/8.jpg)
@fluid_digitalfluid-digital.com
CreatingYourPages
URLstructureforM2iscontrolledbythedirectoryname,filenameandthefrontName setinetc/frontend/routes.xml
/blog/index/index(or/blog)/blog/categories/index(or/blog/categories)
![Page 9: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/9.jpg)
@fluid_digitalfluid-digital.com
![Page 10: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/10.jpg)
@fluid_digitalfluid-digital.com
Creatingthelayout
Eachpageneeds itsownlayoutXMLfile
ThelayoutXMLfilenamesmatchthepreviouslysetURLstructurebutwithunderscoresusedforseparators
frontName_directoryName_controllerName.xml
blog_index_index.xml - usedforthebloglandingpage• frontName – blog• Directory– Index• FileName – Index.php
blog_article_view.xml – usedforthearticlespecificpage• frontName - blog• Directory– Article• FileName – View.php
![Page 11: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/11.jpg)
@fluid_digitalfluid-digital.com
LayoutXMLFile
![Page 12: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/12.jpg)
@fluid_digitalfluid-digital.com
BlockFiles
JustasinMagento1,blockfilescontainfunctions thatareaccessibletotheviewfiles
Theyareusedasaconnectionbetweentheviewandthemodels
HencetheearliertermusedtodescribethedesignpatternMVVM-ModelViewViewModel
![Page 13: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/13.jpg)
@fluid_digitalfluid-digital.com
ModelsModelsinMagento2areverysimilartoMagento1andprovideyouwithCRUDfunctionalityCreate-read-update-delete
Requiredfilesareasfollows:
Model/ModelName.phpModel/Resource/ModelName.phpModel/Resource/ModelName/Collection
![Page 14: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/14.jpg)
@fluid_digitalfluid-digital.com
TemplateFiles
Frontend templatefilesliveinview/frontend/templatedirectory
PrettymuchthesameaMagento1
![Page 15: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/15.jpg)
@fluid_digitalfluid-digital.com
WebFiles(CSS,JS&Images)CSS,JSandimagefilesforamodulearestoredinthedirectory:view/frontend/web/
cssjsimages
LikeMagento1theseareaddedtothepageinthelayoutXMLfileexceptthesyntaxisslightlydifferent
![Page 16: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/16.jpg)
@fluid_digitalfluid-digital.com
FrontendPreview/blog
![Page 17: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/17.jpg)
@fluid_digitalfluid-digital.com
Composer
ComposerallowsyoutoeasilymanagepackagesinMagento
InstallMagento2veryeasilywiththefollowingcommand:composercreate-project--repository-url=https://repo.magento.com/magento/project-community-edition.
Allowsindividualmodules tobeeasilyadded, removedorupgrade
UpgradeMagento2versionbysimplyediting therootcomposer.json filethenrunning composerupdate
![Page 18: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/18.jpg)
@fluid_digitalfluid-digital.com
Howdoescomposertieintoourmodule
Weneed toaddtoourmoduleacomposer.json file
Thisneedstobeaddedtothemodule rootdirectory
Easilyinstallandupdateourmodulecomposer requirefluid/blogcomposerupdate
ConnectstoexternalVCSsuchasgithub
![Page 19: Magento 2 Creating A Custom Module Fluid DigitalMagento 2 Creating A Custom Module Matt Edwards Technical Director Fluid Digital ûXLG GLJLWDO FRP #ûXLGBGLJLWDO Magento 1 vs Magento](https://reader033.vdocuments.site/reader033/viewer/2022042310/5ed7ac7ff0b5d51dff7a3bf2/html5/thumbnails/19.jpg)
fluid-digital.com @fluid_digital
Magento Ecommerce Agency
Questions?