SlideShare a Scribd company logo
1 of 63
Magento 101
Getting Started with Magento Development
Who you are
Magento 101
Getting Started with Magento Development
Crash Course For PHP Developers
Mathew Beane
November 17th 2015
http://joind.in/link
2
Mathew Beane
@aepod
Director of Systems Engineering - Robofirm
Zend Z-Team Volunteer – Magento Division
Family member – 3 Kids and a Wife
Magento Certified Developer
• Open-source PHP E-Commerce Market Leader
• Large community
• Full Featured E-Commerce Platform
• Incredibly Flexible
• Highly Structured
• Steep learning curve because of complexity
• Enterprise Edition offers support and more features
So its not a color, super villain
or an electrical generator?
Magento is an open-source content management
system for e-commerce web sites.
- Wikipedia
Image: Marvel Comics
What is Magento?
Todays tl;dr
The Magento application
Common toolsets for Magento developers
Quick start Magento development
• Brief overview
• Install guide
• Backend development
• Frontend development
About training & certification
Magento 2
4
Magento 101 – Mathew Beane – php[world] 2015
Magento Application
Core Overview – Directories and Designs
5
Magento 1
Community Edition (CE): 1.9.2.1
Enterprise Edition (EE): 1.14.2.0
Still primarily used on live sites.
Magento 2
2.0.0
Just Released, ready for use.
Full refactor, modern OO concepts.
Todays Magento
Community member John Knowles produced this amazing patch guide.
http://magento.com/security/news/which-security-
patches-should-i-update-my-version-magento
Scan for missing patches using the byte tool:
https://www.magereport.com/scan/
Over the last year there has been a serious uptick
in hacker activity aimed at Magento. Do not be
caught unaware, patch today.
Patch Today!
Magento Design Patterns
Selected Design Patterns
Model View Controller Pattern
Business logic happens in the models and the controller maps the model-data
to the views. The block system helps with rendering because Magento is heavy
on the Model/View side.
Front Controller Pattern
Magento uses an index.php which has a single point of entry Mage::app()
which initializes the environment and routes the request to the controller.
Factory Pattern
Heavily used by Magento, a good example is the getModel() function which
accesses models via aliases from the configuration XML.
Module Pattern
Magento relies on a very modular architecture, however a lot of functionality
breaks this due to heavy usage of the Mage core class throughout the
application.
More reading: http://magenticians.com/12-design-patterns-magento
Magento Core Code
Everything in the
Magento zip file or
installed by Magento
should be considered
core code.
Partial List of Core Files
• index.php
• app/code/core
• app/design/[adminhtml,frontend]/[base,default]
• js/jslib_installed_with_magento/
• lib/library_installed_with_magento/
• skin/[adminhtml,frontend]/[base,default]
For a complete list, download current Magento and look through the code.
How to Keep Core Clean
Source: https://joind.in/talk/view/16204
• Magento allows class overrides on nearly
everything.
• Magento’s Event/Observer mechanism is pre-
built into most business logic. You can add
more if you need.
• Designs/Templates have a fallback system that
allows you to utilize any of the core layouts and
templates, or replace them in your current
design.
• Untouched index.php. Outside of development
and very rare implementations you should not
“need” to edit this.
Core Changes That Are OK!
• Patches: Magento releases patches that are not
controlled via composer or version number.
• Updating Shared Libraries: For instance CM_Redis, or a
payment gateway that are included with core Magento.
On your local Copy:
Careful not to commit any changes from core, employ a .gitignore strategy.
• Changing core to learn about Magento is OK
• Changing core to debug is OK.
Magento Core Directory Overview
Path Usage
/app/ Where most of the PHP resides
/js/ External Javascript library. Typically only used by
extensions that are including common assets.
/lib/ “External code library” With lots of core code, this can
also contain 3rd party frameworks and other goodies.
/skin/ CSS, Images and Javascript
/var/ Contains logs, reports, session files and a variety of
other goodies.
Path Usage
/app/code/community Downloaded modules built by Magento 3rd
party developers.
/app/code/core/ Core modules, out of the box Magento, do
not touch.
/app/code/local/ Modules built for the specific
application/store.
Path Usage
/app/etc/local.xml Master configuration file for Magento, contains
database, cache and other settings.
/app/etc/config.xml Default settings, with some directory locations.
Usually this is not touched.
app/etc/modules/ Modules loading configuration files.
/ - Directory Root /app/code/
/app/etc/
Magento Core Design Directories
Path Usage
/app/design/frontend/base/ Default Templates, falls back from any package.
/app/design/frontend/default/ Old pre-rwd base theme default package.
/app/design/frontend/rwd/ RWD is a responsive template package.
Path Usage
/skin/frontend/default/default/css Default theme CSS files
/skin/frontend/default/default/images Default theme image files.
/skin/frontend/default/default/js Default theme javascript files
/app/design/frontend
/skin/frontend/
Magento Core Designs Pattern
Frontend design directories fall into this pattern:
app/design/<area>/<package>/<theme>/[css,images,js]
skin/<area>/<package>/<theme>/[css,images,js]
• Area: Typically frontend or adminhtml.
• Package / Theme: Accommodates Magento’s theme fallback logic.
Package and Theme Fallback Logic
Graph from: http://blog.belvg.com/magento-fallback-configuration-default-and-specific-themes-packages-design-exceptions-temporary-theme-configuration.html
Package: custom_package
Theme: custom_theme
Never edit base/default, or default/default. These should be
considered core code. (Extensions also install in here)
When creating a new design use the override system creating a
custom_package and custom_theme.
Magento 101 – Mathew Beane – php[world] 2015
Magento Application
Core Overview – Configuration and Database
16
Magento Configuration Structure
• XML Based
• xpaths are used as keys in core_config_data table in mysql
• Hierarchical with overrides and scope
• In the app you can call any final config value using the xpath
• Used for configuration values (cached via Configuration Cache)
• Also used for layout rules (cached via Layout Cache)
Magento Configuration Scope
• Global Scope
• Default Values
• Used if not found in scope
• Website Scope
• Website scope is used to override global scope
per website.
• Used to support Multi-Store environments
• View Scope (subset of website scope)
• Used for currency, tax, and language settings
• Typically shown as a dropdown for
Language/Currency
• Limited Configuration Values Available
Magento Admin – Choosing Configuration Scope
Magento Database Interface
Magento uses a basic CRUD Model
There are three basic components to the data
interface
Model: Doesn’t contain database code
Resource Model: Read/Write adapters for communicating
to database
Collection: PHP Object used to hold model instances,
implements several PHP Standard Library interfaces to
work with the collection.
“Most Magento Models can be categorized in one of two ways. There's a basic,
ActiveRecord-like/one-object-one-table Model, and there's also an Entity Attribute
Value (EAV) Model.“
- http://devdocs.magento.com/guides/m1x/magefordev/mage-for-dev-5.html
Magento’s CRUD Resource Model:
Mage_Core_Model_Abstract
• Create & Update: save()
• Read: load()
• Delete: delete()
Magento Database Structure
• Most of the tables are InnoDB
• Several Hundred Tables
• The DB can grow very large due to logging, carts,
and other data
• Typically not edited by hand in any way at any time.
Selected Tablespace Areas:
core_ : Many of the core system settings tables
reside here.
catalog_ : Stores products, categories, associations,
and other data.
customer_ : Stores the customer information
sales_ : Quotes, invoices and orders, and related data
Image Source: https://wiki.smu.edu.sg/is480/2012T2_Team_Chm%3A_Project_Design
Magento 101 – Mathew Beane – php[world] 2015
Magento Common Toolsets
Overview & Best Practices
21
Magento Development IDE Choices
PHPStorm with Magicento Plugin
PHPStorm with the Magicento is also very popular.
https://www.jetbrains.com/phpstorm/
http://magicento.com/
Zend Studio
Built in support for Magento, built on eclipse and a
very nice platform for editing Magento.
http://www.zend.com/en/products/studio
Magento Server Stack Tools
• Magento does well on the Zend Server platform. Zend provides great PHP support. It has Z-
Ray, tools for deployment, monitoring and other features which make it very nice in
production.
• Newrelic: Magento even has an official plugin to send data to newrelic. http://newrelic.com/robofirm
• blackfire.io : Used for tracing code, like newrelic + xhprof.
• Z-Ray: Standalone works very well with the Magento plugin, add to apache/nginx stack.
Z-Ray and the Magento Plugin
• Full Database Queries
• Debug Production & Mobile Devices with
Z-Ray Live
• Fully Extensible – Framework Support
• All Function calls – with details
• Errors and Warnings
• Magento Plugin Provides:
• Detailed Overview
• Events / Observers
• Layouts / Blocks
• Logs / Modules
• Details, details… details!
Magento Application Stack Tools
N98-magerun:
https://github.com/netz98/n98-magerun
A must have CLI tool, the swiss army knife for Magento
Developers.
Alan Storm’s Commerce Bug:
http://store.pulsestorm.net/products/commerce-bug-2
This thing is amazing, best $50 I ever spent on Magento.
N98-magerun in action.
Don’t miss Alan Storms Blog:
http://alanstorm.com/
Magento 101 – Mathew Beane – php[world] 2015
Magento Quick Start
Getting Started With Magento Development
26
Magento Quick Start - Itinerary
• Installation: Manual and automated
methods. Revision control and workflow.
• Development: The basic parts of an
extension.
• Theming and Designs: Frontend
development for Magento.
MTG Card c/o Wizards of the Coast
Magento Quick Start – “The App”
Designs
Layouts: XML Configurations
Templates: PHTML templates
Static Files: CSS, JS and Images
Extensions
Blocks: Template Business Logic
Controllers: Request Routing
Helpers: General Functions
Models: Data and Database Interface
Magento Extension Developers Guide
Figure 3: MVC design pattern for Magento
Magento System Requirements
Operating System
Linux x86-64
Web Server
Apache 2.x
Nginx 1.7.x
Database
MySQL 5.6 (Oracle or Percona)
PHP
PHP 5.4 – 5.5
• Optional Services
Redis
Memcache
Apache SOLR
• Required PHP Extensions
CURL
DOM
gd
hash
Iconv
mcrypt
pcre
pdo
pdo_mysql
simplexml
Magento 101 – Mathew Beane – php[world] 2015
Magento Quick Start
Installation Guide
30
Magento Manual Installation
Installing Magento from scratch is really only a couple basic steps.
1.Create database, database user and proper grants.
2.Copy source files into the webroot.
(Optional) Add sample data to database, and media to webroot/media
3.Set and confirm permissions on all files for webserver.
4.Point web browser at your webroot.
5.Step through the installer.
6.Do any post install tasks, because your done.
http://devdocs.magento.com/guides/m1x/install/installing_install.html
Magento Automated Installation
• https://github.com/rjbaker/simple-magento-vagrant
Name says it all, no puppet or chef. Virtualbox + Vagrant. Magento 1.9.1.0 with
sample data. A little stale.
• https://github.com/mike182uk/magento-dev-vagrant-chef-solo
A more active and configurable vagrant install. Virtualbox, Vagrant and Chef.
Magento 1.9.2.1 with sample data.
• https://hub.docker.com/r/alexcheng/magento/
Ready to go docker container, you will have to do a little configuration to make this
one work. Magento 1.9.1.0, no sample data.
Magento Loves Composer
https://github.com/Cotya/magento-composer-installer
Manage all your extensions, designs, and other stuff via composer.
https://github.com/AydinHassan/magento-core-composer-installer
Manage core install with this community package. It makes it easy to update your core if
you require it using composer.
http://packages.firegento.com/
A community repository of a lot of the common extensions that are used by a lot of
Magento developers.
Keeping Magento Clean Using Git
• git is really required for managing a Magento installation.
• Use symbolic links and .gitignore for volatile directories and sensitive files.
• When used with composer gitignore will require a more complex strategy.
• Checkout Fabrizo Branca’s presentations on this for a very in depth study:
http://www.slideshare.net/aoepeople/rock-solid-magento
http://www.slideshare.net/aoepeople/2014-04-magento-meetup-composer
http://www.slideshare.net/aoepeople/continuous-development-and-deployment-workflows-and-patterns
• Sonassi hass another great guide:
https://www.sonassi.com/knowledge-base/our-magento-git-guide-and-work-flow/
Magento 101 – Mathew Beane – php[world] 2015
Magento Quick Start
Development Guide
35
Magento Extension Structure
Extension / Module Code
Configuration: Module configuration and status values
Blocks: Classes for interfacing with phtml templates
Controllers: Classes that handle request routing
Helpers: General functions and helpers
Models: Resource Models and Collections for DB
Installers/Upgrades: Install, upgrade and even remove extension data
Magento Extensions - Configuration
Module Status
/app/etc/modules/demo_example.xml
<?xml version="1.0"?>
<config>
<modules>
<Demo_Example>
<active>true</active>
<codePool>community</codePool>
</Demo_Example>
</modules>
</config>
Module Config
/app/code/community/Demo/Example/etc/config.xml
• Merged into with the rest of the configuration
• Defines all models, blocks and classes for the module
• Similar to the app/etc/local.xml or data in the
core_config_data table
• Controls installation and updates of module data
Magento Extensions - Designs
• Configuration Files: /app/etc/modules/demo_example.xml
Definitions for Blocks, Layouts and Assets should be declared here.
• Blocks: app/etc/code/community/Demo/Example/Blocks
Classes for interfacing with the templates.
• Layouts: app/design/frontend/base/default/layout/demo_example.xml
XML Configurations for Blocks.
• Templates: app/design/frontend/base/default/template/demo/template.phtml
XML Configurations for Blocks.
• Media: skin/frontend/base/default/[css,images,js]/demo/filename
Extension specific media assets
Magento Extensions - Code
• Controller: /app/code/community/Demo/Example/controllers/Router.php
Dispatched through Front Controller object. Action is matched to class and
method. Controller instances Layout Object which in turn calls Block classes.
• Helper: /app/code/community/Demo/Example/Helper/Data.php
Used whenever you either are too lazy to make a model, or it just doesn’t make
sense in the context of a model. (Does it have an internal state – It’s a model)
• Model: /app/code/community/Demo/Example/Model/Thing.php
Used to model data structures. Oftentimes calling database through Resource
Models. Resource Models wrap all database transactions. Additionally Magento
uses collections to create and iterate through lists of Models.
Using Core Class Overrides
Easy and “Safe” way to override core functionality
Files are placed in:
/app/code/local/Mage/Catalog/Block/Navigation.php
This will override and replace
/app/code/core/Mage/Catalog/Block/Navigation.php
• Copy the file from the original and edit as you
would expect.
• Use this method very sparingly.
• It creates technical debt, because you have to
maintain your “copy” of the core file.
• Not the preferred method and some still
consider this editing core.
Extensions - Rewriting Core Classes
• Still easy and a “Safer” way to override
core functionality
• Requires an extension to create a class
rewrite
• Rewrite class extends core class
• Preserves code through upgrade
• Much safer than just overriding the
whole class because its isolated in an
extension.
• Chain rewrites together to create
complex dependencies
• Winner takes all strategy makes this
bothersome as site grows.
/app/code/community/Demo/Example/etc/config.xml
<config>
<global>
<models>
<catalog>
<rewrite>
<product>Demo_Example_Model_Product</product>
</rewrite>
</catalog>
</models>
</global>
</config>
/app/code/community/Demo/Example/Product.php
<?php
include(‘Mage/Catalog/Model/Product.php’);
class Demo_Example_Model_Product extends Mage_Catalog_Model_Product{
// Functions here will rewrite the Magento Catalog Product Model Class
}
Extensions - Events / Observers
• The proper way to hook into Magento
Business Logic
• Declared in config.xml
• Many Observers to One Event
• Observers are Models in the modules
Model/ directory
• Events are declared for most things you
will need to hook into
• You can add your own Events, combining
this with the Rewrite or Override
methods
/app/code/community/Demo/Example/etc/config.xml
<config>
<global>
<events>
<checkout_cart_product_add_after>
<observers>
<Demo_Example_Model_Observer>
<type>singleton</type>
<class>Demo_Example_Model_Observer</type>
<method>addtocartEvent</method>
</Demo_Example_Model_Observer>
</observers >
</checkout_cart_product_add_after>
</events>
</global>
</config>
/app/code/community/Demo/Example/Model/Observer.php
class Demo_Example_Model_Observer {
public function addtoCartEvent(Varien_Event_Observer $observer){
// Observer Code goes here
}
}
List of events in CE 1.9
https://wiki.magento.com/display/m1wiki/Magento+1.x+Events+Reference
Extensions - Blocks
• Blocks are PHP Objects
• Each block is tied to a single Template
file.
• Inside the Template, $this keyword
refers to the Template’s Block object.
• Blocks can include Blocks nesting them
utilizing the getChildHtml() method.
• Blocks are instanced from the Layout
configuration, typically from layout XML
files.
/app/code/community/Demo/Example/etc/config.xml
<config>
<global>
<blocks>
<exampleblock>
<class>Demo_Example_Block</class>
</exampleblock>
</blocks>
</global>
</config>
/app/code/community/Demo/Example/Block/Product.php
<?php
class Demo_Example_Block_Product extends Mage_Core_Block_Template{
//Functions that would be called in phtml
// they would use the $this->functionName to call them
}
Extensions - Controllers
• Controllers are used to route requests.
• Controllers should be lightweight, keep
business logic out of your controllers.
• No really, keep your logic in helpers or
models.
• Controller matches route
• Class/Method is fired
• Layout Object is instanced, it creates all the
blocks.
• You can extend core controllers:
http://inchoo.net/dev-talk/how-to-extend-magento-core-controller/
• Learn more:
http://alanstorm.com/magento_controller_hello_world
/app/code/community/Demo/Example/etc/config.xml
<config>
<frontend>
<routers>
<examplerouter>
<args>
<module>Demo_Example</module>
<frontName>demoexample</frontname>
</args>
</ examplerouter >
</routers>
</frontend>
</config>
/app/code/community/Demo/Example/controllers/IndexController.php
<?php
class Demo_Example_Block_Product extends Mage_Core_Controller_Front_action
{
public function indexAction(){
// would fire on http://site.com/demoexample
}
}
Extensions – Install / Upgrade Scripts
• Uses the module version in app/etc/module/Demo_Example.xml
and compares against the value in the core_resource table
• Requires resource models to be setup properly
• Install and upgrade scripts live in:
app/code/community/Demo/Example/sql/uniquename/
 Install-0.1.0.1.php would contain and $installer
• This will fire off on ANY request if the config_cache is cleared,
“upgrading” modules, which can be confusing.
• Good Write up on this:
http://alanstorm.com/magento_setup_resources
Installer scripts can be really confusing.
Magento 101 – Mathew Beane – php[world] 2015
Magento Quick Start
Theme and Design Guide
46
Designs and Design Choices
• Designs can easily become extensions and become
dependent on extensions easily.
• Designs are also highly dependent on the front-end HTML
choices that are made.
• Magento has a built in Responsive Design(RWD)
• When designing for an existing or new site, there are a lot
more constraints than when looking at extensions.
Layout XML Files
Layouts can drive how the page is displayed
This example is setting the homepage to be 1 column wide:
<demo_index_index>
<reference name=“root”>
<action method=“setTemplate”>
<template>page/1column.php</template>
</action>
</reference>
</demo_index_index>
Use Commercebug to track down
which pieces of Layout are being
rendered.
Layout XML - Templates and Blocks
Layouts also drive what loads where
(blocks / templates)
Here is an example of displaying the demo module content block:
<demo_index_index>
<reference name=“content”>
<block type=“core/template” name=“demo_content”
template=“demo/demo_content.phtml”>
</reference>
</demo_index_index>
Toggle on Template Path Hints to find
out which piece is loading where on the
page, this can also show block class.
More on Templates and Blocks
Templates are the key to theming in Magento
• Templates are created as “.phtml” documents
• Magic variable “$this” allows us to access parent block class
• Template best practices:
 Frontend components should be as modular as possible
 Logic should only be used when coming directly from parent block class
 Backend logic (i.e. querying data) should NEVER live in templates
 Responsive frameworks make prototyping easier and faster
 Don’t use hard URL paths, or include assets in templates.
One key component to
designs we have skipped over
today is Handles, which are
used to generate the layout
that will be used to render the
templates and blocks.
Acumen – A great starting design
http://themeforest.net/item/acumen-the-highly-extensible-magento-theme/978466
Acumen is a 5 year old theme by Gravity Department
• 960 Grid
• HTML5 + CSS3
• High Quality
• Loaded to the gills with widgets and features
• Maintained by author
• Not Responsive Design
Magento 101 – Mathew Beane – php[world] 2015
Magento Training and
Certification
Learning Magento
52
Magento Training
StackExchange: https://magento.stackexchange.com/
Very active community, easy to get answers.
Magento site: http://magento.com/training/overview
Tons of resources, documentations for Magento 1 is in a great spot.
The on-demand videos are cheap and amazing.
Blogs:
Alan Storm: http://alanstorm.com/
Belvg: http://blog.belvg.com/
Ichoo: http://inchoo.net/category/magento/
Alan MacGregor: http://coderoncode.com/
Alan Kent: http://alankent.me/
Magento Certification
Magento Certifications:
• CERTIFIED SOLUTION SPECIALIST
• FRONT END DEVELOPER
• CERTIFIED DEVELOPER
• CERTIFIED DEVELOPER PLUS
“Experienced Magento professionals can validate their real-world skills by earning a
Magento Certification. Magento Certification Exams are geared toward professionals
who want to differentiate themselves from the competition with the ultimate
Magento credential.”
- http://magento.com/training/catalog/certification
Magento Certification Subjects
Basics: Introduction to Magento code hierarchies, modules and configuration.
Request Flow: Learn how Magento bootstraps itself and handles requests.
Rendering: Understand how pages are rendered - themes, layouts, blocks and templates.
Databases: Discover models, resources models and collections.
EAV: Entity Attribute Value tables, explained.
Adminhtml: Manage admin area forms and grids.
Catalog: Find out about categories, products, layered navigation and taxes.
Checkout: Covering quotes, orders and shipping and payment methods.
Sales: Order creation and management.
Advanced: API and Widgets etc.
Magento Certification Study Guides
http://info.magento.com/rs/magentocommerce/images/Certification-Study-Guide-MCD-v1.pdf
Official study guide, a good starting point for studying for the exam. It will give you a broad overview of the
subjects.
http://magento.com/training/catalog/technical-track
On-demand course, really quite a good course even if a bit dated. Then again, so is the test.
http://magecert.com/
Put together by some of the community as a way to dig into examples for each of the subjects in the test.
http://magento.com/training/catalog/moderators-kit
Cheap alternative, covers the entire gamut of the test and is really a great learning tool for teams.
https://shop.vinaikopp.com/grokking-magento/
A great companion to the moderators kit, with Vinai Kopp taking you through each of the examples for the
first part of the moderator kit.
Magento 101 – Mathew Beane – php[world] 2015
Magento 2
It’s GO TIME!
57
Magento 2.0.0-RC1 Being Released
Magento 2 – Release Information
Six basic Goals of Magento 2
• Modern Tech Stack
• Improved Performance and Scalability
• Streamline Customizations
• Simplify Integrations
• Cleaner Install and Upgrades
• High Quality Code & Testing http://www.elevateweb.co.uk/magento-2/magento-live-uk-2014-magento-2-update
Magento 2 – Under the Hood
http://devdocs.magento.com/guides/v2.0/architecture/archi_perspectives/arch_diagrams.html
• PHP 5.7 / 7 / HHVM Support
• Dependency Injection
• Service Layer/Contracts
• Jquery
• HTML 5, CSS, LESS
• Require.js
• Symfony & other 3rd Party
libraries
• Composer
• Full Test Coverage
Magento 2 – Features Overview
• Very modular with a strong backbone in open-source
• CE will not have all of the scalability and clustering
features
• Many Client-side and frontend enhancements
• Up to 3 master databases for separate business domains
Main (Catalog),Checkout and Order
• Varnish support out of the box (Swapable for FPC)
• Support for RabbitMQ and other queueing systems
Present in the deferred stock update feature
• Asynchronous order insertion
Magento 2.0.0-RC1 Being Released
Magento 2 – Get Involved
https://github.com/magento/magento2
You can branch, make Pull Requests and they are actively participating in issues there.
http://magento.com/developers/magento2
Central hub for all the official Magento 2 information
http://devdocs.magento.com/guides/v2.0/architecture/arch_whatis.html
Documentation, which is still being developed actively. You can branch and PR here as well.
http://magento.com/training/catalog/fundamentals-of-magento-2-development
Magento 2 training course, on-demand. Still in development, however its very inexpensive
right now.
Magento 2 – Learn More Here
Magento 2 Talks at php[world]
• Magento 2 Dependency Injection, Interceptors, and You
Joshua Warren – Today @ 4:30 PM in Ash Grove C
• Magento 2: New and Innovative?
David Alger – Wednesday @ 4:30pm in Potomac
• Extending Magento: Fundamentals of Development in Magento 2
David Alger – Thursday @ 10:00am in Ash Grove C
63
Mathew Beane
Tweeter: @aepod
mbeane@robofirm.com
https://joind.in/talk/view/14815
You – For attending. Thanks for showing up.
My Family – For putting up with me making these slides.
Magento Community – Very good people, deserve a lot of thanks.
PHP Community – For just being so damned cool.
Ben Marks - Community Magento @benmarks on twitter
PHP Architect: Great conferences and real community leadership.
Robofirm – They also put up with me making these slides.
THANKS TO THE FOLLOWING:

More Related Content

What's hot

Codestrong 2012 breakout session introduction to mobile web and best practices
Codestrong 2012 breakout session   introduction to mobile web and best practicesCodestrong 2012 breakout session   introduction to mobile web and best practices
Codestrong 2012 breakout session introduction to mobile web and best practices
Axway Appcelerator
 
Tuning Web Performance
Tuning Web PerformanceTuning Web Performance
Tuning Web Performance
Eric ShangKuan
 

What's hot (19)

WordCamp Montreal 2016 WP-API + React with server rendering
WordCamp Montreal 2016  WP-API + React with server renderingWordCamp Montreal 2016  WP-API + React with server rendering
WordCamp Montreal 2016 WP-API + React with server rendering
 
Maven
MavenMaven
Maven
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Maven
MavenMaven
Maven
 
Apache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikApache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip Hanik
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Maven tutorial for beginners
Maven tutorial for beginnersMaven tutorial for beginners
Maven tutorial for beginners
 
Ad108 - XPages in the IBM Lotus Notes Client - A Deep Dive!
Ad108 - XPages in the IBM Lotus Notes Client - A Deep Dive!Ad108 - XPages in the IBM Lotus Notes Client - A Deep Dive!
Ad108 - XPages in the IBM Lotus Notes Client - A Deep Dive!
 
Maven
Maven Maven
Maven
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
 
Codestrong 2012 breakout session introduction to mobile web and best practices
Codestrong 2012 breakout session   introduction to mobile web and best practicesCodestrong 2012 breakout session   introduction to mobile web and best practices
Codestrong 2012 breakout session introduction to mobile web and best practices
 
Take Your XPages Development to the Next Level
Take Your XPages Development to the Next LevelTake Your XPages Development to the Next Level
Take Your XPages Development to the Next Level
 
From CakePHP to Laravel
From CakePHP to LaravelFrom CakePHP to Laravel
From CakePHP to Laravel
 
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
 
Best Practices in PHP Application Deployment
Best Practices in PHP Application DeploymentBest Practices in PHP Application Deployment
Best Practices in PHP Application Deployment
 
Tuning Web Performance
Tuning Web PerformanceTuning Web Performance
Tuning Web Performance
 
<Head> Presentation: Plugging Into Wordpress
<Head> Presentation: Plugging Into Wordpress<Head> Presentation: Plugging Into Wordpress
<Head> Presentation: Plugging Into Wordpress
 
Maven
MavenMaven
Maven
 

Viewers also liked

Viewers also liked (11)

Automated Testing Talk from Meet Magento New York 2014
Automated Testing Talk from Meet Magento New York 2014Automated Testing Talk from Meet Magento New York 2014
Automated Testing Talk from Meet Magento New York 2014
 
Elk ruminating on logs
Elk ruminating on logsElk ruminating on logs
Elk ruminating on logs
 
ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)
 
Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
Midwest PHP - Scaling Magento
Midwest PHP - Scaling MagentoMidwest PHP - Scaling Magento
Midwest PHP - Scaling Magento
 
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and VarnishMagento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
 
Phpworld.2015 scaling magento
Phpworld.2015 scaling magentoPhpworld.2015 scaling magento
Phpworld.2015 scaling magento
 
Magento 101: A technical overview
Magento 101: A technical overviewMagento 101: A technical overview
Magento 101: A technical overview
 
Checkout in Magento 2 by Max Pronko
Checkout in Magento 2 by Max PronkoCheckout in Magento 2 by Max Pronko
Checkout in Magento 2 by Max Pronko
 
MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2
 

Similar to php[world] Magento101

Optimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend ServerOptimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend Server
varien
 
Zepplin_Pronko_Magento_Festival Hall 1_Final
Zepplin_Pronko_Magento_Festival Hall 1_FinalZepplin_Pronko_Magento_Festival Hall 1_Final
Zepplin_Pronko_Magento_Festival Hall 1_Final
Max Pronko
 
In Act Developers Platform
In Act Developers PlatformIn Act Developers Platform
In Act Developers Platform
Eris Ristemena
 

Similar to php[world] Magento101 (20)

Zendcon magento101
Zendcon magento101Zendcon magento101
Zendcon magento101
 
Optimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend ServerOptimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend Server
 
Magento 2 - Getting started.
Magento 2 - Getting started.Magento 2 - Getting started.
Magento 2 - Getting started.
 
Magento
MagentoMagento
Magento
 
Zepplin_Pronko_Magento_Festival Hall 1_Final
Zepplin_Pronko_Magento_Festival Hall 1_FinalZepplin_Pronko_Magento_Festival Hall 1_Final
Zepplin_Pronko_Magento_Festival Hall 1_Final
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
 
Yoav Kutner Dutchento
Yoav Kutner DutchentoYoav Kutner Dutchento
Yoav Kutner Dutchento
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM i
 
Introduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce PlatformIntroduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce Platform
 
Front End Development in Magento
Front End Development in MagentoFront End Development in Magento
Front End Development in Magento
 
Cakephp manual-11
Cakephp manual-11Cakephp manual-11
Cakephp manual-11
 
green
greengreen
green
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 
Aop, Metaprogramming and codegeneration with PHP
Aop, Metaprogramming and codegeneration with PHPAop, Metaprogramming and codegeneration with PHP
Aop, Metaprogramming and codegeneration with PHP
 
In Act Developers Platform
In Act Developers PlatformIn Act Developers Platform
In Act Developers Platform
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento Cloud
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento
 
Mangento
MangentoMangento
Mangento
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
IDE and Toolset For Magento Development
IDE and Toolset For Magento DevelopmentIDE and Toolset For Magento Development
IDE and Toolset For Magento Development
 

Recently uploaded

75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
Asmae Rabhi
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
ayvbos
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
pxcywzqs
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
galaxypingy
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
ydyuyu
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 

Recently uploaded (20)

75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolino
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 

php[world] Magento101

  • 1. Magento 101 Getting Started with Magento Development Who you are Magento 101 Getting Started with Magento Development Crash Course For PHP Developers Mathew Beane November 17th 2015 http://joind.in/link
  • 2. 2 Mathew Beane @aepod Director of Systems Engineering - Robofirm Zend Z-Team Volunteer – Magento Division Family member – 3 Kids and a Wife Magento Certified Developer
  • 3. • Open-source PHP E-Commerce Market Leader • Large community • Full Featured E-Commerce Platform • Incredibly Flexible • Highly Structured • Steep learning curve because of complexity • Enterprise Edition offers support and more features So its not a color, super villain or an electrical generator? Magento is an open-source content management system for e-commerce web sites. - Wikipedia Image: Marvel Comics What is Magento?
  • 4. Todays tl;dr The Magento application Common toolsets for Magento developers Quick start Magento development • Brief overview • Install guide • Backend development • Frontend development About training & certification Magento 2 4
  • 5. Magento 101 – Mathew Beane – php[world] 2015 Magento Application Core Overview – Directories and Designs 5
  • 6. Magento 1 Community Edition (CE): 1.9.2.1 Enterprise Edition (EE): 1.14.2.0 Still primarily used on live sites. Magento 2 2.0.0 Just Released, ready for use. Full refactor, modern OO concepts. Todays Magento
  • 7. Community member John Knowles produced this amazing patch guide. http://magento.com/security/news/which-security- patches-should-i-update-my-version-magento Scan for missing patches using the byte tool: https://www.magereport.com/scan/ Over the last year there has been a serious uptick in hacker activity aimed at Magento. Do not be caught unaware, patch today. Patch Today!
  • 8. Magento Design Patterns Selected Design Patterns Model View Controller Pattern Business logic happens in the models and the controller maps the model-data to the views. The block system helps with rendering because Magento is heavy on the Model/View side. Front Controller Pattern Magento uses an index.php which has a single point of entry Mage::app() which initializes the environment and routes the request to the controller. Factory Pattern Heavily used by Magento, a good example is the getModel() function which accesses models via aliases from the configuration XML. Module Pattern Magento relies on a very modular architecture, however a lot of functionality breaks this due to heavy usage of the Mage core class throughout the application. More reading: http://magenticians.com/12-design-patterns-magento
  • 9. Magento Core Code Everything in the Magento zip file or installed by Magento should be considered core code. Partial List of Core Files • index.php • app/code/core • app/design/[adminhtml,frontend]/[base,default] • js/jslib_installed_with_magento/ • lib/library_installed_with_magento/ • skin/[adminhtml,frontend]/[base,default] For a complete list, download current Magento and look through the code.
  • 10. How to Keep Core Clean Source: https://joind.in/talk/view/16204 • Magento allows class overrides on nearly everything. • Magento’s Event/Observer mechanism is pre- built into most business logic. You can add more if you need. • Designs/Templates have a fallback system that allows you to utilize any of the core layouts and templates, or replace them in your current design. • Untouched index.php. Outside of development and very rare implementations you should not “need” to edit this.
  • 11. Core Changes That Are OK! • Patches: Magento releases patches that are not controlled via composer or version number. • Updating Shared Libraries: For instance CM_Redis, or a payment gateway that are included with core Magento. On your local Copy: Careful not to commit any changes from core, employ a .gitignore strategy. • Changing core to learn about Magento is OK • Changing core to debug is OK.
  • 12. Magento Core Directory Overview Path Usage /app/ Where most of the PHP resides /js/ External Javascript library. Typically only used by extensions that are including common assets. /lib/ “External code library” With lots of core code, this can also contain 3rd party frameworks and other goodies. /skin/ CSS, Images and Javascript /var/ Contains logs, reports, session files and a variety of other goodies. Path Usage /app/code/community Downloaded modules built by Magento 3rd party developers. /app/code/core/ Core modules, out of the box Magento, do not touch. /app/code/local/ Modules built for the specific application/store. Path Usage /app/etc/local.xml Master configuration file for Magento, contains database, cache and other settings. /app/etc/config.xml Default settings, with some directory locations. Usually this is not touched. app/etc/modules/ Modules loading configuration files. / - Directory Root /app/code/ /app/etc/
  • 13. Magento Core Design Directories Path Usage /app/design/frontend/base/ Default Templates, falls back from any package. /app/design/frontend/default/ Old pre-rwd base theme default package. /app/design/frontend/rwd/ RWD is a responsive template package. Path Usage /skin/frontend/default/default/css Default theme CSS files /skin/frontend/default/default/images Default theme image files. /skin/frontend/default/default/js Default theme javascript files /app/design/frontend /skin/frontend/
  • 14. Magento Core Designs Pattern Frontend design directories fall into this pattern: app/design/<area>/<package>/<theme>/[css,images,js] skin/<area>/<package>/<theme>/[css,images,js] • Area: Typically frontend or adminhtml. • Package / Theme: Accommodates Magento’s theme fallback logic.
  • 15. Package and Theme Fallback Logic Graph from: http://blog.belvg.com/magento-fallback-configuration-default-and-specific-themes-packages-design-exceptions-temporary-theme-configuration.html Package: custom_package Theme: custom_theme Never edit base/default, or default/default. These should be considered core code. (Extensions also install in here) When creating a new design use the override system creating a custom_package and custom_theme.
  • 16. Magento 101 – Mathew Beane – php[world] 2015 Magento Application Core Overview – Configuration and Database 16
  • 17. Magento Configuration Structure • XML Based • xpaths are used as keys in core_config_data table in mysql • Hierarchical with overrides and scope • In the app you can call any final config value using the xpath • Used for configuration values (cached via Configuration Cache) • Also used for layout rules (cached via Layout Cache)
  • 18. Magento Configuration Scope • Global Scope • Default Values • Used if not found in scope • Website Scope • Website scope is used to override global scope per website. • Used to support Multi-Store environments • View Scope (subset of website scope) • Used for currency, tax, and language settings • Typically shown as a dropdown for Language/Currency • Limited Configuration Values Available Magento Admin – Choosing Configuration Scope
  • 19. Magento Database Interface Magento uses a basic CRUD Model There are three basic components to the data interface Model: Doesn’t contain database code Resource Model: Read/Write adapters for communicating to database Collection: PHP Object used to hold model instances, implements several PHP Standard Library interfaces to work with the collection. “Most Magento Models can be categorized in one of two ways. There's a basic, ActiveRecord-like/one-object-one-table Model, and there's also an Entity Attribute Value (EAV) Model.“ - http://devdocs.magento.com/guides/m1x/magefordev/mage-for-dev-5.html Magento’s CRUD Resource Model: Mage_Core_Model_Abstract • Create & Update: save() • Read: load() • Delete: delete()
  • 20. Magento Database Structure • Most of the tables are InnoDB • Several Hundred Tables • The DB can grow very large due to logging, carts, and other data • Typically not edited by hand in any way at any time. Selected Tablespace Areas: core_ : Many of the core system settings tables reside here. catalog_ : Stores products, categories, associations, and other data. customer_ : Stores the customer information sales_ : Quotes, invoices and orders, and related data Image Source: https://wiki.smu.edu.sg/is480/2012T2_Team_Chm%3A_Project_Design
  • 21. Magento 101 – Mathew Beane – php[world] 2015 Magento Common Toolsets Overview & Best Practices 21
  • 22. Magento Development IDE Choices PHPStorm with Magicento Plugin PHPStorm with the Magicento is also very popular. https://www.jetbrains.com/phpstorm/ http://magicento.com/ Zend Studio Built in support for Magento, built on eclipse and a very nice platform for editing Magento. http://www.zend.com/en/products/studio
  • 23. Magento Server Stack Tools • Magento does well on the Zend Server platform. Zend provides great PHP support. It has Z- Ray, tools for deployment, monitoring and other features which make it very nice in production. • Newrelic: Magento even has an official plugin to send data to newrelic. http://newrelic.com/robofirm • blackfire.io : Used for tracing code, like newrelic + xhprof. • Z-Ray: Standalone works very well with the Magento plugin, add to apache/nginx stack.
  • 24. Z-Ray and the Magento Plugin • Full Database Queries • Debug Production & Mobile Devices with Z-Ray Live • Fully Extensible – Framework Support • All Function calls – with details • Errors and Warnings • Magento Plugin Provides: • Detailed Overview • Events / Observers • Layouts / Blocks • Logs / Modules • Details, details… details!
  • 25. Magento Application Stack Tools N98-magerun: https://github.com/netz98/n98-magerun A must have CLI tool, the swiss army knife for Magento Developers. Alan Storm’s Commerce Bug: http://store.pulsestorm.net/products/commerce-bug-2 This thing is amazing, best $50 I ever spent on Magento. N98-magerun in action. Don’t miss Alan Storms Blog: http://alanstorm.com/
  • 26. Magento 101 – Mathew Beane – php[world] 2015 Magento Quick Start Getting Started With Magento Development 26
  • 27. Magento Quick Start - Itinerary • Installation: Manual and automated methods. Revision control and workflow. • Development: The basic parts of an extension. • Theming and Designs: Frontend development for Magento. MTG Card c/o Wizards of the Coast
  • 28. Magento Quick Start – “The App” Designs Layouts: XML Configurations Templates: PHTML templates Static Files: CSS, JS and Images Extensions Blocks: Template Business Logic Controllers: Request Routing Helpers: General Functions Models: Data and Database Interface Magento Extension Developers Guide Figure 3: MVC design pattern for Magento
  • 29. Magento System Requirements Operating System Linux x86-64 Web Server Apache 2.x Nginx 1.7.x Database MySQL 5.6 (Oracle or Percona) PHP PHP 5.4 – 5.5 • Optional Services Redis Memcache Apache SOLR • Required PHP Extensions CURL DOM gd hash Iconv mcrypt pcre pdo pdo_mysql simplexml
  • 30. Magento 101 – Mathew Beane – php[world] 2015 Magento Quick Start Installation Guide 30
  • 31. Magento Manual Installation Installing Magento from scratch is really only a couple basic steps. 1.Create database, database user and proper grants. 2.Copy source files into the webroot. (Optional) Add sample data to database, and media to webroot/media 3.Set and confirm permissions on all files for webserver. 4.Point web browser at your webroot. 5.Step through the installer. 6.Do any post install tasks, because your done. http://devdocs.magento.com/guides/m1x/install/installing_install.html
  • 32. Magento Automated Installation • https://github.com/rjbaker/simple-magento-vagrant Name says it all, no puppet or chef. Virtualbox + Vagrant. Magento 1.9.1.0 with sample data. A little stale. • https://github.com/mike182uk/magento-dev-vagrant-chef-solo A more active and configurable vagrant install. Virtualbox, Vagrant and Chef. Magento 1.9.2.1 with sample data. • https://hub.docker.com/r/alexcheng/magento/ Ready to go docker container, you will have to do a little configuration to make this one work. Magento 1.9.1.0, no sample data.
  • 33. Magento Loves Composer https://github.com/Cotya/magento-composer-installer Manage all your extensions, designs, and other stuff via composer. https://github.com/AydinHassan/magento-core-composer-installer Manage core install with this community package. It makes it easy to update your core if you require it using composer. http://packages.firegento.com/ A community repository of a lot of the common extensions that are used by a lot of Magento developers.
  • 34. Keeping Magento Clean Using Git • git is really required for managing a Magento installation. • Use symbolic links and .gitignore for volatile directories and sensitive files. • When used with composer gitignore will require a more complex strategy. • Checkout Fabrizo Branca’s presentations on this for a very in depth study: http://www.slideshare.net/aoepeople/rock-solid-magento http://www.slideshare.net/aoepeople/2014-04-magento-meetup-composer http://www.slideshare.net/aoepeople/continuous-development-and-deployment-workflows-and-patterns • Sonassi hass another great guide: https://www.sonassi.com/knowledge-base/our-magento-git-guide-and-work-flow/
  • 35. Magento 101 – Mathew Beane – php[world] 2015 Magento Quick Start Development Guide 35
  • 36. Magento Extension Structure Extension / Module Code Configuration: Module configuration and status values Blocks: Classes for interfacing with phtml templates Controllers: Classes that handle request routing Helpers: General functions and helpers Models: Resource Models and Collections for DB Installers/Upgrades: Install, upgrade and even remove extension data
  • 37. Magento Extensions - Configuration Module Status /app/etc/modules/demo_example.xml <?xml version="1.0"?> <config> <modules> <Demo_Example> <active>true</active> <codePool>community</codePool> </Demo_Example> </modules> </config> Module Config /app/code/community/Demo/Example/etc/config.xml • Merged into with the rest of the configuration • Defines all models, blocks and classes for the module • Similar to the app/etc/local.xml or data in the core_config_data table • Controls installation and updates of module data
  • 38. Magento Extensions - Designs • Configuration Files: /app/etc/modules/demo_example.xml Definitions for Blocks, Layouts and Assets should be declared here. • Blocks: app/etc/code/community/Demo/Example/Blocks Classes for interfacing with the templates. • Layouts: app/design/frontend/base/default/layout/demo_example.xml XML Configurations for Blocks. • Templates: app/design/frontend/base/default/template/demo/template.phtml XML Configurations for Blocks. • Media: skin/frontend/base/default/[css,images,js]/demo/filename Extension specific media assets
  • 39. Magento Extensions - Code • Controller: /app/code/community/Demo/Example/controllers/Router.php Dispatched through Front Controller object. Action is matched to class and method. Controller instances Layout Object which in turn calls Block classes. • Helper: /app/code/community/Demo/Example/Helper/Data.php Used whenever you either are too lazy to make a model, or it just doesn’t make sense in the context of a model. (Does it have an internal state – It’s a model) • Model: /app/code/community/Demo/Example/Model/Thing.php Used to model data structures. Oftentimes calling database through Resource Models. Resource Models wrap all database transactions. Additionally Magento uses collections to create and iterate through lists of Models.
  • 40. Using Core Class Overrides Easy and “Safe” way to override core functionality Files are placed in: /app/code/local/Mage/Catalog/Block/Navigation.php This will override and replace /app/code/core/Mage/Catalog/Block/Navigation.php • Copy the file from the original and edit as you would expect. • Use this method very sparingly. • It creates technical debt, because you have to maintain your “copy” of the core file. • Not the preferred method and some still consider this editing core.
  • 41. Extensions - Rewriting Core Classes • Still easy and a “Safer” way to override core functionality • Requires an extension to create a class rewrite • Rewrite class extends core class • Preserves code through upgrade • Much safer than just overriding the whole class because its isolated in an extension. • Chain rewrites together to create complex dependencies • Winner takes all strategy makes this bothersome as site grows. /app/code/community/Demo/Example/etc/config.xml <config> <global> <models> <catalog> <rewrite> <product>Demo_Example_Model_Product</product> </rewrite> </catalog> </models> </global> </config> /app/code/community/Demo/Example/Product.php <?php include(‘Mage/Catalog/Model/Product.php’); class Demo_Example_Model_Product extends Mage_Catalog_Model_Product{ // Functions here will rewrite the Magento Catalog Product Model Class }
  • 42. Extensions - Events / Observers • The proper way to hook into Magento Business Logic • Declared in config.xml • Many Observers to One Event • Observers are Models in the modules Model/ directory • Events are declared for most things you will need to hook into • You can add your own Events, combining this with the Rewrite or Override methods /app/code/community/Demo/Example/etc/config.xml <config> <global> <events> <checkout_cart_product_add_after> <observers> <Demo_Example_Model_Observer> <type>singleton</type> <class>Demo_Example_Model_Observer</type> <method>addtocartEvent</method> </Demo_Example_Model_Observer> </observers > </checkout_cart_product_add_after> </events> </global> </config> /app/code/community/Demo/Example/Model/Observer.php class Demo_Example_Model_Observer { public function addtoCartEvent(Varien_Event_Observer $observer){ // Observer Code goes here } } List of events in CE 1.9 https://wiki.magento.com/display/m1wiki/Magento+1.x+Events+Reference
  • 43. Extensions - Blocks • Blocks are PHP Objects • Each block is tied to a single Template file. • Inside the Template, $this keyword refers to the Template’s Block object. • Blocks can include Blocks nesting them utilizing the getChildHtml() method. • Blocks are instanced from the Layout configuration, typically from layout XML files. /app/code/community/Demo/Example/etc/config.xml <config> <global> <blocks> <exampleblock> <class>Demo_Example_Block</class> </exampleblock> </blocks> </global> </config> /app/code/community/Demo/Example/Block/Product.php <?php class Demo_Example_Block_Product extends Mage_Core_Block_Template{ //Functions that would be called in phtml // they would use the $this->functionName to call them }
  • 44. Extensions - Controllers • Controllers are used to route requests. • Controllers should be lightweight, keep business logic out of your controllers. • No really, keep your logic in helpers or models. • Controller matches route • Class/Method is fired • Layout Object is instanced, it creates all the blocks. • You can extend core controllers: http://inchoo.net/dev-talk/how-to-extend-magento-core-controller/ • Learn more: http://alanstorm.com/magento_controller_hello_world /app/code/community/Demo/Example/etc/config.xml <config> <frontend> <routers> <examplerouter> <args> <module>Demo_Example</module> <frontName>demoexample</frontname> </args> </ examplerouter > </routers> </frontend> </config> /app/code/community/Demo/Example/controllers/IndexController.php <?php class Demo_Example_Block_Product extends Mage_Core_Controller_Front_action { public function indexAction(){ // would fire on http://site.com/demoexample } }
  • 45. Extensions – Install / Upgrade Scripts • Uses the module version in app/etc/module/Demo_Example.xml and compares against the value in the core_resource table • Requires resource models to be setup properly • Install and upgrade scripts live in: app/code/community/Demo/Example/sql/uniquename/  Install-0.1.0.1.php would contain and $installer • This will fire off on ANY request if the config_cache is cleared, “upgrading” modules, which can be confusing. • Good Write up on this: http://alanstorm.com/magento_setup_resources Installer scripts can be really confusing.
  • 46. Magento 101 – Mathew Beane – php[world] 2015 Magento Quick Start Theme and Design Guide 46
  • 47. Designs and Design Choices • Designs can easily become extensions and become dependent on extensions easily. • Designs are also highly dependent on the front-end HTML choices that are made. • Magento has a built in Responsive Design(RWD) • When designing for an existing or new site, there are a lot more constraints than when looking at extensions.
  • 48. Layout XML Files Layouts can drive how the page is displayed This example is setting the homepage to be 1 column wide: <demo_index_index> <reference name=“root”> <action method=“setTemplate”> <template>page/1column.php</template> </action> </reference> </demo_index_index> Use Commercebug to track down which pieces of Layout are being rendered.
  • 49. Layout XML - Templates and Blocks Layouts also drive what loads where (blocks / templates) Here is an example of displaying the demo module content block: <demo_index_index> <reference name=“content”> <block type=“core/template” name=“demo_content” template=“demo/demo_content.phtml”> </reference> </demo_index_index> Toggle on Template Path Hints to find out which piece is loading where on the page, this can also show block class.
  • 50. More on Templates and Blocks Templates are the key to theming in Magento • Templates are created as “.phtml” documents • Magic variable “$this” allows us to access parent block class • Template best practices:  Frontend components should be as modular as possible  Logic should only be used when coming directly from parent block class  Backend logic (i.e. querying data) should NEVER live in templates  Responsive frameworks make prototyping easier and faster  Don’t use hard URL paths, or include assets in templates. One key component to designs we have skipped over today is Handles, which are used to generate the layout that will be used to render the templates and blocks.
  • 51. Acumen – A great starting design http://themeforest.net/item/acumen-the-highly-extensible-magento-theme/978466 Acumen is a 5 year old theme by Gravity Department • 960 Grid • HTML5 + CSS3 • High Quality • Loaded to the gills with widgets and features • Maintained by author • Not Responsive Design
  • 52. Magento 101 – Mathew Beane – php[world] 2015 Magento Training and Certification Learning Magento 52
  • 53. Magento Training StackExchange: https://magento.stackexchange.com/ Very active community, easy to get answers. Magento site: http://magento.com/training/overview Tons of resources, documentations for Magento 1 is in a great spot. The on-demand videos are cheap and amazing. Blogs: Alan Storm: http://alanstorm.com/ Belvg: http://blog.belvg.com/ Ichoo: http://inchoo.net/category/magento/ Alan MacGregor: http://coderoncode.com/ Alan Kent: http://alankent.me/
  • 54. Magento Certification Magento Certifications: • CERTIFIED SOLUTION SPECIALIST • FRONT END DEVELOPER • CERTIFIED DEVELOPER • CERTIFIED DEVELOPER PLUS “Experienced Magento professionals can validate their real-world skills by earning a Magento Certification. Magento Certification Exams are geared toward professionals who want to differentiate themselves from the competition with the ultimate Magento credential.” - http://magento.com/training/catalog/certification
  • 55. Magento Certification Subjects Basics: Introduction to Magento code hierarchies, modules and configuration. Request Flow: Learn how Magento bootstraps itself and handles requests. Rendering: Understand how pages are rendered - themes, layouts, blocks and templates. Databases: Discover models, resources models and collections. EAV: Entity Attribute Value tables, explained. Adminhtml: Manage admin area forms and grids. Catalog: Find out about categories, products, layered navigation and taxes. Checkout: Covering quotes, orders and shipping and payment methods. Sales: Order creation and management. Advanced: API and Widgets etc.
  • 56. Magento Certification Study Guides http://info.magento.com/rs/magentocommerce/images/Certification-Study-Guide-MCD-v1.pdf Official study guide, a good starting point for studying for the exam. It will give you a broad overview of the subjects. http://magento.com/training/catalog/technical-track On-demand course, really quite a good course even if a bit dated. Then again, so is the test. http://magecert.com/ Put together by some of the community as a way to dig into examples for each of the subjects in the test. http://magento.com/training/catalog/moderators-kit Cheap alternative, covers the entire gamut of the test and is really a great learning tool for teams. https://shop.vinaikopp.com/grokking-magento/ A great companion to the moderators kit, with Vinai Kopp taking you through each of the examples for the first part of the moderator kit.
  • 57. Magento 101 – Mathew Beane – php[world] 2015 Magento 2 It’s GO TIME! 57 Magento 2.0.0-RC1 Being Released
  • 58. Magento 2 – Release Information Six basic Goals of Magento 2 • Modern Tech Stack • Improved Performance and Scalability • Streamline Customizations • Simplify Integrations • Cleaner Install and Upgrades • High Quality Code & Testing http://www.elevateweb.co.uk/magento-2/magento-live-uk-2014-magento-2-update
  • 59. Magento 2 – Under the Hood http://devdocs.magento.com/guides/v2.0/architecture/archi_perspectives/arch_diagrams.html • PHP 5.7 / 7 / HHVM Support • Dependency Injection • Service Layer/Contracts • Jquery • HTML 5, CSS, LESS • Require.js • Symfony & other 3rd Party libraries • Composer • Full Test Coverage
  • 60. Magento 2 – Features Overview • Very modular with a strong backbone in open-source • CE will not have all of the scalability and clustering features • Many Client-side and frontend enhancements • Up to 3 master databases for separate business domains Main (Catalog),Checkout and Order • Varnish support out of the box (Swapable for FPC) • Support for RabbitMQ and other queueing systems Present in the deferred stock update feature • Asynchronous order insertion Magento 2.0.0-RC1 Being Released
  • 61. Magento 2 – Get Involved https://github.com/magento/magento2 You can branch, make Pull Requests and they are actively participating in issues there. http://magento.com/developers/magento2 Central hub for all the official Magento 2 information http://devdocs.magento.com/guides/v2.0/architecture/arch_whatis.html Documentation, which is still being developed actively. You can branch and PR here as well. http://magento.com/training/catalog/fundamentals-of-magento-2-development Magento 2 training course, on-demand. Still in development, however its very inexpensive right now.
  • 62. Magento 2 – Learn More Here Magento 2 Talks at php[world] • Magento 2 Dependency Injection, Interceptors, and You Joshua Warren – Today @ 4:30 PM in Ash Grove C • Magento 2: New and Innovative? David Alger – Wednesday @ 4:30pm in Potomac • Extending Magento: Fundamentals of Development in Magento 2 David Alger – Thursday @ 10:00am in Ash Grove C
  • 63. 63 Mathew Beane Tweeter: @aepod mbeane@robofirm.com https://joind.in/talk/view/14815 You – For attending. Thanks for showing up. My Family – For putting up with me making these slides. Magento Community – Very good people, deserve a lot of thanks. PHP Community – For just being so damned cool. Ben Marks - Community Magento @benmarks on twitter PHP Architect: Great conferences and real community leadership. Robofirm – They also put up with me making these slides. THANKS TO THE FOLLOWING:

Editor's Notes

  1. Magento employs the MySQL relational database management system, the PHP programming language, and elements of the Zend Framework. It applies the conventions of object-oriented programming and model-view-controller architecture. Magento also uses the entity–attribute–value model to store data. - Wikipedia You can learn a LOT about php from Magento.
  2. You cannot extend the following classes: Mage_Core_Block_Template, Mage_Core_Model_Abstract, Varien_Object, Mage_Core_Block_Abstract, Mage_Customer_Model_Address_Abstract 
  3. The same fallback strategy that is present for design layout and template files is present for skin assets. If files are not found in your selected <package>/<theme> the application will follow the fallback strategy and find the appropriate files in the default directories. We come back to this in a minute.
  4. The first place Magento will look for a file is app/design/frontend/Custom_Package/Custom_theme/ skin/frontend/Custom_Package/Custom_theme If Magento cannot find the file in Custom Package/Custom Theme it will look in: app/design/frontend/Custom_Package /default skin/frontend/Custom_Package/default If Magento cannot find the file in Custom_Package/default it will look in: app/design/frontend/base/default skin/frontend/base/default
  5. Collections implement: IteratorAggregate and Countable Model Collections as arrays that also have methods attached.
  6. Seeing 400-500 tables or more is not unusual Many are index or flat data tables.
  7. Installation: Manual and automated installation methods. And a short discussion of source control. Development: The basic parts of an extension. Designs: Layouts and templates.
  8. We are going to be moving quickly through this coursework.
  9. Installation: Manual and automated installation methods. And a short discussion of source control. Development: The basic parts of an extension. Designs: Layouts and templates.
  10. Installation: Manual and automated installation methods. And a short discussion of source control. Development: The basic parts of an extension. Designs: Layouts and templates.
  11. Keep calm, check the version # again and carry on.
  12. Installation: Manual and automated installation methods. And a short discussion of source control. Development: The basic parts of an extension. Designs: Layouts and templates.
  13. Each page request in Magento will generate several unique Handles.  You can think of the Package Layout similar to the global config. It's a large XML file that contains every possible layout configuration for a particular Magento install. 
  14. Layouts are also used to add js, css etc to the page. They are very powerful.
  15. Layouts are also used to add js, css etc to the page. They are very powerful.
  16. Service Layer is a set of interfaces used to define the public api of a module. Allows for the use of the repository pattern (abstract the way data is mapped out to an object, db can be anything)