SlideShare a Scribd company logo
{
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 2
Magestore
 
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
Joshua 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 benchmarks
Yireo
 
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
David Alger
 
Max Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMax Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overview
Meet 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] 2015
Joshua Warren
 
12 Amazing Features of Magento 2
12 Amazing Features of Magento 212 Amazing Features of Magento 2
12 Amazing Features of Magento 2
Schogini Systems Pvt Ltd
 
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
Magenest
 
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 Counts
Joshua Warren
 
php[world] Magento101
php[world] Magento101php[world] Magento101
php[world] Magento101
Mathew Beane
 
Outlook on Magento 2
Outlook on Magento 2Outlook on Magento 2
Outlook on Magento 2
Matthias Glitzner-Zeis
 
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
Joshua Warren
 
Rapid application development with FOF
Rapid application development with FOFRapid application development with FOF
Rapid application development with FOF
Nicholas 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 performance
Meet Magento Italy
 
Jab12 - Joomla! architecture revealed
Jab12 - Joomla! architecture revealedJab12 - Joomla! architecture revealed
Jab12 - Joomla! architecture revealed
Ofer Cohen
 
Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento Version
Meet 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 2
Vladimir Kerkhoff
 
Hyvä: Compatibility Modules
Hyvä: Compatibility ModulesHyvä: Compatibility Modules
Hyvä: Compatibility Modules
vinaikopp
 

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 Success
Kissmetrics 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 Strategies
Kissmetrics on SlideShare
 
Magento 2: Modernizing an eCommerce Powerhouse
Magento 2: Modernizing an eCommerce PowerhouseMagento 2: Modernizing an eCommerce Powerhouse
Magento 2: Modernizing an eCommerce Powerhouse
Ben Marks
 
Magento 2 product import export
Magento 2 product import exportMagento 2 product import export
Magento 2 product import export
Benno 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 Server
APPSeCONNECT
 
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
Kissmetrics 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 & Lava
Kissmetrics 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 Guide
Amasty
 
30 60 90 day plan
30 60 90 day plan30 60 90 day plan
30 60 90 day plan
Emerald Technology
 
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
Divante
 
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 Experience
Divante
 
Creating a Winning Internet Strategy
Creating a Winning Internet StrategyCreating a Winning Internet Strategy
Creating a Winning Internet Strategy
Dave Chaffey
 
Essential Ecommerce Marketing Tools
Essential Ecommerce Marketing ToolsEssential Ecommerce Marketing Tools
Essential Ecommerce Marketing Tools
Dave 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 plan
Michael 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 today
Dave 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 Strategy
Jonathon Colman
 
Magento best practices
Magento best practicesMagento best practices
Magento best practices
Alessandro Ronchi
 

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 catalyst
dwm042
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
Wildan 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 framework
Dinh 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
 
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
Kenneth Rohde Christiansen
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
zonathen
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento
Ravi Mehrotra
 
Mangento
MangentoMangento
Mangento
Ravi Mehrotra
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в MagentoMagecom Ukraine
 
On Coding Guidelines
On Coding GuidelinesOn Coding Guidelines
On Coding Guidelines
DIlawar 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 Pignataro
Steven Pignataro
 
Website Security
Website SecurityWebsite Security
Website SecurityCarlos Z
 
Website Security
Website SecurityWebsite Security
Website Security
MODxpo
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - Tryout
Matthias 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 4
Darwin 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 devepolment
Rajib 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
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento
 
Mangento
MangentoMangento
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 Developers
Ben Marks
 
Magento 2 Module in 50 Minutes
Magento 2 Module in 50 MinutesMagento 2 Module in 50 Minutes
Magento 2 Module in 50 Minutes
Ben Marks
 
Open Source Commerce Melee
Open Source Commerce MeleeOpen Source Commerce Melee
Open Source Commerce Melee
Ben Marks
 
A World Without PHP
A World Without PHPA World Without PHP
A World Without PHP
Ben Marks
 
Magento 2 Development Best Practices
Magento 2 Development Best PracticesMagento 2 Development Best Practices
Magento 2 Development Best Practices
Ben Marks
 
Your First Magento 2 Module
Your First Magento 2 ModuleYour First Magento 2 Module
Your First Magento 2 Module
Ben 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 Potential
Ben Marks
 
Open Source eCommerce: PHP Power
Open Source eCommerce: PHP PowerOpen Source eCommerce: PHP Power
Open Source eCommerce: PHP Power
Ben 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

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 

Recently uploaded (20)

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 

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