SlideShare a Scribd company logo
1 of 55
Download to read offline
{
Finding Your Way
Understanding Magento Code // @benmarks
https://joind.in/talk/view/8147
Ben Marks
4.5 years doing Magento dev
2 years as a Magento U instructor
Happily employed at Blue Acorn in
Charleston, SC (we're hiring!)
Big fan of questions (ask away)
Who am I?
Who knows Magento?
Who are you?
Who knows Magento?
Who hates Magento?
Who are you?
Who knows Magento?
Who hates Magento?
Who doesn't know Magento, but has been
told that they should hate it?
Who are you?
Who knows Magento?
Who hates Magento?
Who doesn't know Magento, but has been
told that they should hate it?
"Magento doesn't do anything very well" –
Harper Reed, php|tek, 2013
Who are you?
ZF1-based MVC framework
eCommerce Application
Answer to osCommerce
What is Magento?
LOTS of business
LOTS of developer community members
LOTS of room for innovation
LOTS of flexibility
Layout XML
What makes Magento awesome?
LOTS of undocumented features &
conventions
LOTS of bad information out there
LOTS of architecture to scale
LOTS of flexibility
Layout XML
What makes Magento difficult?
Supressed error output (index.php):
Caching on by default (Admin Panel):
Disabled output (admin), disabled local code
pool (app/etc/local.xml)
Getting Started: Don't Forget!
Declaration: app/etc/modules/
Code pool*
Type-specific folders
Theme assets
Modules & Module Structure
Declaration: app/etc/modules/
Points to app/code/core/Mage/Connect/etc/config.xml
All modules have config, and all config is merged
Modules & Module Structure
 Typical classname-to-path mapping, e.g.:
 See app/Mage.php & lib/Varien/Autoload.php:
app/code/local/, app/code/community/, app/cod
e/core/, lib/
 But... Magento is "all about options," so...
Typical Autoloading
Mage_Catalog_Model_Product_Type
Mage/Catalog/Model/Product/Type.php
 Reading class group notation
Mage::getModel('catalog/product_type')
<config>
<global>
<models>
<catalog>
<class>Mage_Catalog_Model
Factory Methods & Class Groups
 Allows for rewrites:
Mage::getModel('catalog/product_type')
<config>
<global>
<models>
<catalog>
<rewrite>
<product_type>New_Class
Factory Methods & Class Groups
 Mage::getModel()
 Mage::helper()*
 Mage::app()->getLayout()->createBlock()
See Mage_Core_Model_Config
::getGroupedClassName()
That's the M, V, and H... but C works
differently
Factory Methods & Class Groups
Standard route matching:
http://tek13.dev/catalog/product/view/id/51
frontName / controller / action
SEF rewrites: core_url_rewrite table
Controllers
Similar cofiguration-based approach, e.g.:
Mage/Catalog/etc/config.xml
Maps to Mage/Catalog/controllers/
Note: not autoloaded
Controllers
Class rewrite/additional route configuration:
Maps to Custom/Module/controllers/
Controllers
Mage_Core_Model_Layout
Factory method for instantiating blocks
Global block registry
Effectively a singleton, accessed via:
 $controller->getLayout()
 Mage::app()->getLayout()
 $block->getLayout()
The View: Layout Object
Blocks have two main workflows
 Instantiation: _construct() & _prepareLayout()
 Rendering:
toHtml(), _beforeToHtml(), _afterToHtml()
Blocks are generally responsible for
instantiating data models/collections –
important for view flexibility
The View: Blocks
Rendering is a waterfall down parent-child
relationships:
$parentBlock->getChildHtml('child');
$child->getChildHtml('etc');
//and so forth...
The View: Blocks
How do blocks get called in to scope for
rendering? In other words, how does stuff get
rendered?
The View: Blocks
Layout XML - up to the developer to use, not
use, mix as needed; keep controllers thin!
The View: Layout XML
Layout XML - up to the developer to use, not
use, mix as needed; keep controllers thin!
public function exampleAction()
{
$this->loadLayout()->renderLayout();
//$this->getResponse()->setBody('Hi!');
}
The View: Layout XML
Declared in module config.xml; all module
layout XML files are compiled always
Layout Update Handles are responsible for
limiting the directives for current scope
Full Action Name handle – the missing link
The View: Layout XML
<contacts_index_index />
<block /> - type, name, as, template
<reference /> - name
<remove /> - name
<update /> - handle
<action /> - method
action allows to call block public methods
The View: Layout XML
Layout update handles: applied via PHP;
top-level nodes in layout XML files
Block type is class group notation:
<block type="page/html_head">
<action method="addJs">
<file>example.js</file>
Mage_Page_Block_Html_Head->addJs('example.js');
The View: Layout XML
Parent-child relationships are established via
markup in layout XML...
The View: Layout XML
...and this relationship is seen in templates as
well:
Required for rendering to work
The View: Layout XML
Parent-child block relationships can also be
set/unset using <action />:
<reference name="root">
<action method="unsetChild">
<child>content</child>
</action>
</reference>
Child exists, but "outside" of rendering flow
The View: Layout XML
Most important thing to understand:
Via layout XML any module can affect any view
through the full action name handle or other
applied handle (customer_logged_in, etc.)
Let's see some examples from catalog.xml
The View: Layout XML
Config XML is composed of the following:
 app/etc/*.xml
 app/etc/modules/*.xml
 All active module config.xml
 app/etc/local.xml
 core_config_data table
Configuration XML
Confusingly accessed/evaluated/built; better
to learn it by application
Important top level nodes:
 global
 frontend & adminhtml
 admin
 default, websites, & stores; often, user-
configurable values here
Configuration XML
Website and store scopes are admin-
configurable, but affect config DOM
structure (System > Manage Stores)
Possible to declare same xpaths in multiple
files and in core_config_data table* (*for
default, websites, and stores)
Colliding xpath text values are overwritten
when merged
Configuration XML
Convenience method for reading correct
value for store scopes
Mage::getStoreConfig('foo/bar/baz');
//same as...
Mage::getConfig()->getNode(
'stores/[code]/foo/bar/baz'
);
Configuration XML
Sometimes it's the node name being
evaluated (e.g. module declaration); most of
the time it's the text node
Bottom line, it's all about the xpath and the
PHP which is evaluating it
Configuration XML
System XML is the quickest way to add user-
configurable fields to the admin panel
Default values can be set in files or added to
core_config_data via setup scripts
Let's look at Mage/Contacts/etc/system.xml
System XML
Magento CRUD:
 Create & Update: save()
 Read: load()
 Delete: delete()
Data model CRUD works through resource
model (see Mage_Core_Model_Abstract)
The Model Layer: CRUD
Hybrid resource / data model classes
Filtering, sorting, etc. Lazy loaded.
Implement Countable &
IteratorAggregate, making it possible to do
this:
The Model Layer: Collections
Generally the best way to customize
Events are dispatched throughout core code
Allow to execute code uniformly (e.g. during
request dispatching) or during specific flow
of execution (catalog_product_load_after)
Observers
Varien_Object (lib/Varien/Object.php)
Basis of blocks and models; for
models, methods map to table columns or
attributes
get*, set*, uns*, & has*
$model->getFooBar()
reads from
$model->_data['foo_bar']
Missing code: when __call strikes
Caveat: nothing stops classes from defining
getters, setters, etc.
Don't var_dump() objects directly; use
Varien_Object->debug() to see
properties in _data
Missing code: when __call
strikes
The action and the template are the most
important aspects to deciphering layout
XML; not all blocks use template!
Find the block class via type
Check the definition to see if the method is
declared or not
A simple echo get_class($this) in the
template will suffice
Missing code: layout XML
Observer configuration can be found mainly
under the xpaths
global/events, frontend/events, and
adminhtml/events
Many events are dynamic
Multiple observers can be configured for the
same event
Missing code: Observers
When an install is not behaving as
expected, check for Mage, Varien, and Zend
namespaces outside of core or lib
Check for event observer configuration for
targeted CRUD and reques operations
Missing code: Miscellaneous
When content is being rendered with no
apparent source in template or entity
data, suspect translations, which can reside
in translate.csv, app/locale/, or core_translate
table; translate="" & __("Some String")
CMS pages, categories, and products all
have custom design settings (themes &
layout XML) which are stored in the
database
Missing code: Miscellaneous
Module code not executing.
Is config being merged? Enable developer
mode & clear cache. Error message indicates
everything is ok. 80% of all problems start
with config.*
Troubleshooting Process
Unexpected or missing theme-related content.
Reset the theme to default to rule out issues
from custom templates & layout XML; check
database for layout XML, template, and theme
settings. Check parent-child relationships.
Troubleshooting Process
Class XYZ is not behaving correctly.
Check for a config-based rewrite, an include
path override, or an event observer.
Collection class/view seems to be slow.
Ensure that the collection class is building
correct data and that models are not being
loaded iteratively.
Troubleshooting Process
Enable profiler in two places:
 System > Configuration > Developer
 index.php - uncomment Varien_Profiler::enable()
Rudimentary output; read from outside-in till
you get to the bottom-most entry with longest
execution time
Enable query profiler in config xml at
global/resources/default_setup/connection/profiler
Profiler
 Enable TPH in admin:
 System > Configuraration > Developer
 Change scope from "Default"
 Pretty ugly, and missing key info (such as
alias, name). Check out AOE_TemplateHints
v2.0 http://www.fabrizio-branca.de/magento-
advanced-template-hints-20.html
Template Path Hints
ben@blueacorn.com
http://twitter.com/benmarks
Me
http://stackoverflow.com/questions/tagged/
magento
http://magento.stackexchange.com/
http://alanstorm.com/
http://magebase.com/
http://www.fabrizio-branca.de/magento-
modules.html
http://blueacorn.com/
Resources
Magicento plugin for PhpStorm
http://magicento.com/
n98-magerun:
https://github.com/netz98/n98-magerun
Feedback:
https://joind.in/talk/view/8147
Resources

More Related Content

What's hot

How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2Magestore
 
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015Joshua Warren
 
How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]M-Connect Media
 
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarksMagento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarksYireo
 
Magento 2: New and Innovative? - php[world] 2015
Magento 2: New and Innovative? - php[world] 2015Magento 2: New and Innovative? - php[world] 2015
Magento 2: New and Innovative? - php[world] 2015David Alger
 
Max Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMax Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMeet Magento Italy
 
How I Learned to Stop Worrying and Love Composer - php[world] 2015
How I Learned to Stop Worrying and Love Composer - php[world] 2015How I Learned to Stop Worrying and Love Composer - php[world] 2015
How I Learned to Stop Worrying and Love Composer - php[world] 2015Joshua Warren
 
Magento 2 Theme Trainning for Beginners | Magenest
Magento 2 Theme Trainning for Beginners | MagenestMagento 2 Theme Trainning for Beginners | Magenest
Magento 2 Theme Trainning for Beginners | MagenestMagenest
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhubMagento Dev
 
Magento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second CountsMagento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second CountsJoshua Warren
 
php[world] Magento101
php[world] Magento101php[world] Magento101
php[world] Magento101Mathew Beane
 
Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016
Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016
Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016Joshua Warren
 
Rapid application development with FOF
Rapid application development with FOFRapid application development with FOF
Rapid application development with FOFNicholas Dionysopoulos
 
Oleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performanceOleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performanceMeet Magento Italy
 
Jab12 - Joomla! architecture revealed
Jab12 - Joomla! architecture revealedJab12 - Joomla! architecture revealed
Jab12 - Joomla! architecture revealedOfer Cohen
 
Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionMeet Magento Italy
 
Convert Magento 1 Extensions to Magento 2
Convert Magento 1 Extensions to Magento 2Convert Magento 1 Extensions to Magento 2
Convert Magento 1 Extensions to Magento 2Vladimir Kerkhoff
 
Hyvä: Compatibility Modules
Hyvä: Compatibility ModulesHyvä: Compatibility Modules
Hyvä: Compatibility Modulesvinaikopp
 

What's hot (20)

How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2
 
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
 
How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]
 
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarksMagento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarks
 
Magento 2: New and Innovative? - php[world] 2015
Magento 2: New and Innovative? - php[world] 2015Magento 2: New and Innovative? - php[world] 2015
Magento 2: New and Innovative? - php[world] 2015
 
Max Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMax Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overview
 
How I Learned to Stop Worrying and Love Composer - php[world] 2015
How I Learned to Stop Worrying and Love Composer - php[world] 2015How I Learned to Stop Worrying and Love Composer - php[world] 2015
How I Learned to Stop Worrying and Love Composer - php[world] 2015
 
12 Amazing Features of Magento 2
12 Amazing Features of Magento 212 Amazing Features of Magento 2
12 Amazing Features of Magento 2
 
Magento 2 Theme Trainning for Beginners | Magenest
Magento 2 Theme Trainning for Beginners | MagenestMagento 2 Theme Trainning for Beginners | Magenest
Magento 2 Theme Trainning for Beginners | Magenest
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhub
 
Magento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second CountsMagento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second Counts
 
php[world] Magento101
php[world] Magento101php[world] Magento101
php[world] Magento101
 
Outlook on Magento 2
Outlook on Magento 2Outlook on Magento 2
Outlook on Magento 2
 
Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016
Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016
Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016
 
Rapid application development with FOF
Rapid application development with FOFRapid application development with FOF
Rapid application development with FOF
 
Oleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performanceOleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performance
 
Jab12 - Joomla! architecture revealed
Jab12 - Joomla! architecture revealedJab12 - Joomla! architecture revealed
Jab12 - Joomla! architecture revealed
 
Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento Version
 
Convert Magento 1 Extensions to Magento 2
Convert Magento 1 Extensions to Magento 2Convert Magento 1 Extensions to Magento 2
Convert Magento 1 Extensions to Magento 2
 
Hyvä: Compatibility Modules
Hyvä: Compatibility ModulesHyvä: Compatibility Modules
Hyvä: Compatibility Modules
 

Viewers also liked

The Holidays Are Coming (Again!): 4 Ecommerce PPC Tricks to Master for Success
The Holidays Are Coming (Again!): 4 Ecommerce PPC Tricks to Master for SuccessThe Holidays Are Coming (Again!): 4 Ecommerce PPC Tricks to Master for Success
The Holidays Are Coming (Again!): 4 Ecommerce PPC Tricks to Master for SuccessKissmetrics on SlideShare
 
How to Build Data-Driven B2B Growth Strategies
How to Build Data-Driven B2B Growth StrategiesHow to Build Data-Driven B2B Growth Strategies
How to Build Data-Driven B2B Growth StrategiesKissmetrics on SlideShare
 
Magento 2: Modernizing an eCommerce Powerhouse
Magento 2: Modernizing an eCommerce PowerhouseMagento 2: Modernizing an eCommerce Powerhouse
Magento 2: Modernizing an eCommerce PowerhouseBen Marks
 
Magento 2 product import export
Magento 2 product import exportMagento 2 product import export
Magento 2 product import exportBenno Lippert
 
How to Install Magento on WAMP Server
How to Install Magento on WAMP ServerHow to Install Magento on WAMP Server
How to Install Magento on WAMP ServerAPPSeCONNECT
 
Key CRO Metrics to Analyze for Successful Landing Pages
Key CRO Metrics to Analyze for Successful Landing PagesKey CRO Metrics to Analyze for Successful Landing Pages
Key CRO Metrics to Analyze for Successful Landing PagesKissmetrics on SlideShare
 
The PPC Traffic Thermometer - Why You Should Care About Ice Cubes & Lava
The PPC Traffic Thermometer - Why You Should Care About Ice Cubes & LavaThe PPC Traffic Thermometer - Why You Should Care About Ice Cubes & Lava
The PPC Traffic Thermometer - Why You Should Care About Ice Cubes & LavaKissmetrics on SlideShare
 
Shipping Table Rates for Magento 2 by Amasty | User Guide
Shipping Table Rates for Magento 2 by Amasty | User GuideShipping Table Rates for Magento 2 by Amasty | User Guide
Shipping Table Rates for Magento 2 by Amasty | User GuideAmasty
 
Surprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusinessSurprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusinessDivante
 
30 60 90 Day Sales Action Plan
30 60 90 Day Sales Action Plan 30 60 90 Day Sales Action Plan
30 60 90 Day Sales Action Plan Gordon Kiser
 
Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)Divante
 
Omnichannel Customer Experience
Omnichannel Customer ExperienceOmnichannel Customer Experience
Omnichannel Customer ExperienceDivante
 
Creating a Winning Internet Strategy
Creating a Winning Internet StrategyCreating a Winning Internet Strategy
Creating a Winning Internet StrategyDave Chaffey
 
Essential Ecommerce Marketing Tools
Essential Ecommerce Marketing ToolsEssential Ecommerce Marketing Tools
Essential Ecommerce Marketing ToolsDave Chaffey
 
LeadingAST.com - Sample 90 day leadership plan
LeadingAST.com - Sample 90 day leadership planLeadingAST.com - Sample 90 day leadership plan
LeadingAST.com - Sample 90 day leadership planMichael Weening
 
5 things that still surprise me about Digital Marketing today
5 things that still surprise me about Digital Marketing today5 things that still surprise me about Digital Marketing today
5 things that still surprise me about Digital Marketing todayDave Chaffey
 
How to Build SEO into Content Strategy
How to Build SEO into Content StrategyHow to Build SEO into Content Strategy
How to Build SEO into Content StrategyJonathon Colman
 

Viewers also liked (20)

The Holidays Are Coming (Again!): 4 Ecommerce PPC Tricks to Master for Success
The Holidays Are Coming (Again!): 4 Ecommerce PPC Tricks to Master for SuccessThe Holidays Are Coming (Again!): 4 Ecommerce PPC Tricks to Master for Success
The Holidays Are Coming (Again!): 4 Ecommerce PPC Tricks to Master for Success
 
How to Build Data-Driven B2B Growth Strategies
How to Build Data-Driven B2B Growth StrategiesHow to Build Data-Driven B2B Growth Strategies
How to Build Data-Driven B2B Growth Strategies
 
Magento 2: Modernizing an eCommerce Powerhouse
Magento 2: Modernizing an eCommerce PowerhouseMagento 2: Modernizing an eCommerce Powerhouse
Magento 2: Modernizing an eCommerce Powerhouse
 
Magento 2 product import export
Magento 2 product import exportMagento 2 product import export
Magento 2 product import export
 
How to Install Magento on WAMP Server
How to Install Magento on WAMP ServerHow to Install Magento on WAMP Server
How to Install Magento on WAMP Server
 
Key CRO Metrics to Analyze for Successful Landing Pages
Key CRO Metrics to Analyze for Successful Landing PagesKey CRO Metrics to Analyze for Successful Landing Pages
Key CRO Metrics to Analyze for Successful Landing Pages
 
The PPC Traffic Thermometer - Why You Should Care About Ice Cubes & Lava
The PPC Traffic Thermometer - Why You Should Care About Ice Cubes & LavaThe PPC Traffic Thermometer - Why You Should Care About Ice Cubes & Lava
The PPC Traffic Thermometer - Why You Should Care About Ice Cubes & Lava
 
Shipping Table Rates for Magento 2 by Amasty | User Guide
Shipping Table Rates for Magento 2 by Amasty | User GuideShipping Table Rates for Magento 2 by Amasty | User Guide
Shipping Table Rates for Magento 2 by Amasty | User Guide
 
30 60 90 day plan
30 60 90 day plan30 60 90 day plan
30 60 90 day plan
 
Surprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusinessSurprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusiness
 
30 60 90 Day Sales Action Plan
30 60 90 Day Sales Action Plan 30 60 90 Day Sales Action Plan
30 60 90 Day Sales Action Plan
 
Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)
 
Omnichannel Customer Experience
Omnichannel Customer ExperienceOmnichannel Customer Experience
Omnichannel Customer Experience
 
Creating a Winning Internet Strategy
Creating a Winning Internet StrategyCreating a Winning Internet Strategy
Creating a Winning Internet Strategy
 
Essential Ecommerce Marketing Tools
Essential Ecommerce Marketing ToolsEssential Ecommerce Marketing Tools
Essential Ecommerce Marketing Tools
 
LeadingAST.com - Sample 90 day leadership plan
LeadingAST.com - Sample 90 day leadership planLeadingAST.com - Sample 90 day leadership plan
LeadingAST.com - Sample 90 day leadership plan
 
5 things that still surprise me about Digital Marketing today
5 things that still surprise me about Digital Marketing today5 things that still surprise me about Digital Marketing today
5 things that still surprise me about Digital Marketing today
 
How to Build SEO into Content Strategy
How to Build SEO into Content StrategyHow to Build SEO into Content Strategy
How to Build SEO into Content Strategy
 
Magento best practices
Magento best practicesMagento best practices
Magento best practices
 
Magento code audit
Magento code auditMagento code audit
Magento code audit
 

Similar to Finding Your Way: Understanding Magento Code

Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP frameworkDinh Pham
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkNguyen Duc Phu
 
Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Nelson Gomes
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento Ravi Mehrotra
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в MagentoMagecom Ukraine
 
On Coding Guidelines
On Coding GuidelinesOn Coding Guidelines
On Coding GuidelinesDIlawar Singh
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroSteven Pignataro
 
Website Security
Website SecurityWebsite Security
Website SecurityCarlos Z
 
Website Security
Website SecurityWebsite Security
Website SecurityMODxpo
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - TryoutMatthias Noback
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handlingSuite Solutions
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Darwin Biler
 
Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!mold
 
Starting with PHP and Web devepolment
Starting with PHP and Web devepolmentStarting with PHP and Web devepolment
Starting with PHP and Web devepolmentRajib Ahmed
 

Similar to Finding Your Way: Understanding Magento Code (20)

Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP framework
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
 
Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.
 
HTML literals, the JSX of the platform
HTML literals, the JSX of the platformHTML literals, the JSX of the platform
HTML literals, the JSX of the platform
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Mangento
MangentoMangento
Mangento
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
 
On Coding Guidelines
On Coding GuidelinesOn Coding Guidelines
On Coding Guidelines
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
Website Security
Website SecurityWebsite Security
Website Security
 
Website Security
Website SecurityWebsite Security
Website Security
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - Tryout
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
 
Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!
 
Starting with PHP and Web devepolment
Starting with PHP and Web devepolmentStarting with PHP and Web devepolment
Starting with PHP and Web devepolment
 

More from Ben Marks

PWA for PHP Developers
PWA for PHP DevelopersPWA for PHP Developers
PWA for PHP DevelopersBen Marks
 
Magento 2 Module in 50 Minutes
Magento 2 Module in 50 MinutesMagento 2 Module in 50 Minutes
Magento 2 Module in 50 MinutesBen Marks
 
Open Source Commerce Melee
Open Source Commerce MeleeOpen Source Commerce Melee
Open Source Commerce MeleeBen Marks
 
A World Without PHP
A World Without PHPA World Without PHP
A World Without PHPBen Marks
 
Magento 2 Development Best Practices
Magento 2 Development Best PracticesMagento 2 Development Best Practices
Magento 2 Development Best PracticesBen Marks
 
Your First Magento 2 Module
Your First Magento 2 ModuleYour First Magento 2 Module
Your First Magento 2 ModuleBen Marks
 
eCommerce and Open Source: Pot, PHP, and Unlimited Potential
eCommerce and Open Source: Pot, PHP, and Unlimited PotentialeCommerce and Open Source: Pot, PHP, and Unlimited Potential
eCommerce and Open Source: Pot, PHP, and Unlimited PotentialBen Marks
 
Open Source eCommerce: PHP Power
Open Source eCommerce: PHP PowerOpen Source eCommerce: PHP Power
Open Source eCommerce: PHP PowerBen Marks
 

More from Ben Marks (8)

PWA for PHP Developers
PWA for PHP DevelopersPWA for PHP Developers
PWA for PHP Developers
 
Magento 2 Module in 50 Minutes
Magento 2 Module in 50 MinutesMagento 2 Module in 50 Minutes
Magento 2 Module in 50 Minutes
 
Open Source Commerce Melee
Open Source Commerce MeleeOpen Source Commerce Melee
Open Source Commerce Melee
 
A World Without PHP
A World Without PHPA World Without PHP
A World Without PHP
 
Magento 2 Development Best Practices
Magento 2 Development Best PracticesMagento 2 Development Best Practices
Magento 2 Development Best Practices
 
Your First Magento 2 Module
Your First Magento 2 ModuleYour First Magento 2 Module
Your First Magento 2 Module
 
eCommerce and Open Source: Pot, PHP, and Unlimited Potential
eCommerce and Open Source: Pot, PHP, and Unlimited PotentialeCommerce and Open Source: Pot, PHP, and Unlimited Potential
eCommerce and Open Source: Pot, PHP, and Unlimited Potential
 
Open Source eCommerce: PHP Power
Open Source eCommerce: PHP PowerOpen Source eCommerce: PHP Power
Open Source eCommerce: PHP Power
 

Recently uploaded

BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsArubSultan
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Osopher
 

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristics
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
 

Finding Your Way: Understanding Magento Code

  • 1. { Finding Your Way Understanding Magento Code // @benmarks https://joind.in/talk/view/8147
  • 2. Ben Marks 4.5 years doing Magento dev 2 years as a Magento U instructor Happily employed at Blue Acorn in Charleston, SC (we're hiring!) Big fan of questions (ask away) Who am I?
  • 4. Who knows Magento? Who hates Magento? Who are you?
  • 5. Who knows Magento? Who hates Magento? Who doesn't know Magento, but has been told that they should hate it? Who are you?
  • 6. Who knows Magento? Who hates Magento? Who doesn't know Magento, but has been told that they should hate it? "Magento doesn't do anything very well" – Harper Reed, php|tek, 2013 Who are you?
  • 7. ZF1-based MVC framework eCommerce Application Answer to osCommerce What is Magento?
  • 8. LOTS of business LOTS of developer community members LOTS of room for innovation LOTS of flexibility Layout XML What makes Magento awesome?
  • 9. LOTS of undocumented features & conventions LOTS of bad information out there LOTS of architecture to scale LOTS of flexibility Layout XML What makes Magento difficult?
  • 10. Supressed error output (index.php): Caching on by default (Admin Panel): Disabled output (admin), disabled local code pool (app/etc/local.xml) Getting Started: Don't Forget!
  • 11. Declaration: app/etc/modules/ Code pool* Type-specific folders Theme assets Modules & Module Structure
  • 12. Declaration: app/etc/modules/ Points to app/code/core/Mage/Connect/etc/config.xml All modules have config, and all config is merged Modules & Module Structure
  • 13.  Typical classname-to-path mapping, e.g.:  See app/Mage.php & lib/Varien/Autoload.php: app/code/local/, app/code/community/, app/cod e/core/, lib/  But... Magento is "all about options," so... Typical Autoloading Mage_Catalog_Model_Product_Type Mage/Catalog/Model/Product/Type.php
  • 14.  Reading class group notation Mage::getModel('catalog/product_type') <config> <global> <models> <catalog> <class>Mage_Catalog_Model Factory Methods & Class Groups
  • 15.  Allows for rewrites: Mage::getModel('catalog/product_type') <config> <global> <models> <catalog> <rewrite> <product_type>New_Class Factory Methods & Class Groups
  • 16.  Mage::getModel()  Mage::helper()*  Mage::app()->getLayout()->createBlock() See Mage_Core_Model_Config ::getGroupedClassName() That's the M, V, and H... but C works differently Factory Methods & Class Groups
  • 17. Standard route matching: http://tek13.dev/catalog/product/view/id/51 frontName / controller / action SEF rewrites: core_url_rewrite table Controllers
  • 18. Similar cofiguration-based approach, e.g.: Mage/Catalog/etc/config.xml Maps to Mage/Catalog/controllers/ Note: not autoloaded Controllers
  • 19. Class rewrite/additional route configuration: Maps to Custom/Module/controllers/ Controllers
  • 20. Mage_Core_Model_Layout Factory method for instantiating blocks Global block registry Effectively a singleton, accessed via:  $controller->getLayout()  Mage::app()->getLayout()  $block->getLayout() The View: Layout Object
  • 21. Blocks have two main workflows  Instantiation: _construct() & _prepareLayout()  Rendering: toHtml(), _beforeToHtml(), _afterToHtml() Blocks are generally responsible for instantiating data models/collections – important for view flexibility The View: Blocks
  • 22. Rendering is a waterfall down parent-child relationships: $parentBlock->getChildHtml('child'); $child->getChildHtml('etc'); //and so forth... The View: Blocks
  • 23. How do blocks get called in to scope for rendering? In other words, how does stuff get rendered? The View: Blocks
  • 24. Layout XML - up to the developer to use, not use, mix as needed; keep controllers thin! The View: Layout XML
  • 25. Layout XML - up to the developer to use, not use, mix as needed; keep controllers thin! public function exampleAction() { $this->loadLayout()->renderLayout(); //$this->getResponse()->setBody('Hi!'); } The View: Layout XML
  • 26. Declared in module config.xml; all module layout XML files are compiled always Layout Update Handles are responsible for limiting the directives for current scope Full Action Name handle – the missing link The View: Layout XML
  • 27. <contacts_index_index /> <block /> - type, name, as, template <reference /> - name <remove /> - name <update /> - handle <action /> - method action allows to call block public methods The View: Layout XML
  • 28. Layout update handles: applied via PHP; top-level nodes in layout XML files Block type is class group notation: <block type="page/html_head"> <action method="addJs"> <file>example.js</file> Mage_Page_Block_Html_Head->addJs('example.js'); The View: Layout XML
  • 29. Parent-child relationships are established via markup in layout XML... The View: Layout XML
  • 30. ...and this relationship is seen in templates as well: Required for rendering to work The View: Layout XML
  • 31. Parent-child block relationships can also be set/unset using <action />: <reference name="root"> <action method="unsetChild"> <child>content</child> </action> </reference> Child exists, but "outside" of rendering flow The View: Layout XML
  • 32. Most important thing to understand: Via layout XML any module can affect any view through the full action name handle or other applied handle (customer_logged_in, etc.) Let's see some examples from catalog.xml The View: Layout XML
  • 33. Config XML is composed of the following:  app/etc/*.xml  app/etc/modules/*.xml  All active module config.xml  app/etc/local.xml  core_config_data table Configuration XML
  • 34. Confusingly accessed/evaluated/built; better to learn it by application Important top level nodes:  global  frontend & adminhtml  admin  default, websites, & stores; often, user- configurable values here Configuration XML
  • 35. Website and store scopes are admin- configurable, but affect config DOM structure (System > Manage Stores) Possible to declare same xpaths in multiple files and in core_config_data table* (*for default, websites, and stores) Colliding xpath text values are overwritten when merged Configuration XML
  • 36. Convenience method for reading correct value for store scopes Mage::getStoreConfig('foo/bar/baz'); //same as... Mage::getConfig()->getNode( 'stores/[code]/foo/bar/baz' ); Configuration XML
  • 37. Sometimes it's the node name being evaluated (e.g. module declaration); most of the time it's the text node Bottom line, it's all about the xpath and the PHP which is evaluating it Configuration XML
  • 38. System XML is the quickest way to add user- configurable fields to the admin panel Default values can be set in files or added to core_config_data via setup scripts Let's look at Mage/Contacts/etc/system.xml System XML
  • 39. Magento CRUD:  Create & Update: save()  Read: load()  Delete: delete() Data model CRUD works through resource model (see Mage_Core_Model_Abstract) The Model Layer: CRUD
  • 40. Hybrid resource / data model classes Filtering, sorting, etc. Lazy loaded. Implement Countable & IteratorAggregate, making it possible to do this: The Model Layer: Collections
  • 41. Generally the best way to customize Events are dispatched throughout core code Allow to execute code uniformly (e.g. during request dispatching) or during specific flow of execution (catalog_product_load_after) Observers
  • 42. Varien_Object (lib/Varien/Object.php) Basis of blocks and models; for models, methods map to table columns or attributes get*, set*, uns*, & has* $model->getFooBar() reads from $model->_data['foo_bar'] Missing code: when __call strikes
  • 43. Caveat: nothing stops classes from defining getters, setters, etc. Don't var_dump() objects directly; use Varien_Object->debug() to see properties in _data Missing code: when __call strikes
  • 44. The action and the template are the most important aspects to deciphering layout XML; not all blocks use template! Find the block class via type Check the definition to see if the method is declared or not A simple echo get_class($this) in the template will suffice Missing code: layout XML
  • 45. Observer configuration can be found mainly under the xpaths global/events, frontend/events, and adminhtml/events Many events are dynamic Multiple observers can be configured for the same event Missing code: Observers
  • 46. When an install is not behaving as expected, check for Mage, Varien, and Zend namespaces outside of core or lib Check for event observer configuration for targeted CRUD and reques operations Missing code: Miscellaneous
  • 47. When content is being rendered with no apparent source in template or entity data, suspect translations, which can reside in translate.csv, app/locale/, or core_translate table; translate="" & __("Some String") CMS pages, categories, and products all have custom design settings (themes & layout XML) which are stored in the database Missing code: Miscellaneous
  • 48. Module code not executing. Is config being merged? Enable developer mode & clear cache. Error message indicates everything is ok. 80% of all problems start with config.* Troubleshooting Process
  • 49. Unexpected or missing theme-related content. Reset the theme to default to rule out issues from custom templates & layout XML; check database for layout XML, template, and theme settings. Check parent-child relationships. Troubleshooting Process
  • 50. Class XYZ is not behaving correctly. Check for a config-based rewrite, an include path override, or an event observer. Collection class/view seems to be slow. Ensure that the collection class is building correct data and that models are not being loaded iteratively. Troubleshooting Process
  • 51. Enable profiler in two places:  System > Configuration > Developer  index.php - uncomment Varien_Profiler::enable() Rudimentary output; read from outside-in till you get to the bottom-most entry with longest execution time Enable query profiler in config xml at global/resources/default_setup/connection/profiler Profiler
  • 52.  Enable TPH in admin:  System > Configuraration > Developer  Change scope from "Default"  Pretty ugly, and missing key info (such as alias, name). Check out AOE_TemplateHints v2.0 http://www.fabrizio-branca.de/magento- advanced-template-hints-20.html Template Path Hints
  • 55. Magicento plugin for PhpStorm http://magicento.com/ n98-magerun: https://github.com/netz98/n98-magerun Feedback: https://joind.in/talk/view/8147 Resources