SlideShare a Scribd company logo
How	
  to	
  write	
  Custom	
  
Modules	
  for	
  PHP-­based	
  E-­
Commerce	
  Systems	
  
Roman	
  Z.	
  
Roman	
  Zenner	
  
•  Working	
  as	
  freelance	
  trainer,	
  author	
  and	
  
consultant	
  since	
  2004	
  
•  Has	
  written	
  three	
  books	
  on	
  Magento	
  and	
  
OXID	
  eShop	
  
•  Is	
  in	
  the	
  process	
  of	
  writing	
  a	
  “cookbook”	
  
on	
  OXID	
  eShop	
  with	
  Joscha	
  Krug	
  
•  Publishes	
  in	
  various	
  magazines	
  
Initial	
  thoughts	
  
•  Modularity	
  a	
  no-­‐brainer	
  in	
  today’s	
  
ecommerce	
  software	
  
•  There	
  must	
  be	
  a	
  way	
  of	
  extending	
  classes	
  
or	
  an	
  event-­‐listener	
  system	
  in	
  order	
  to	
  
integrate	
  custom	
  functionalities	
  
Types	
  of	
  modules	
  
•  Encapsulate	
  graphical	
  (template)	
  
changes	
  
•  Provide	
  additional	
  information	
  (e.g.	
  for	
  
an	
  article	
  
•  Special	
  calculations	
  
•  Payment	
  and	
  shipping	
  
•  Other	
  interfaces	
  (ImpEx,	
  etc.)	
  
Today‘s	
  candidates	
  
•  Magento	
  
•  OXID	
  eShop	
  
•  Shopware	
  
http://www.flickr.com/photos/exey/3815327201
Brief	
  History	
  
•  First	
  stable	
  version	
  released	
  in	
  spring	
  2008	
  
•  Community	
  Edition	
  under	
  OSL	
  
•  Professional	
  and	
  Enterprise	
  Editions	
  
•  Based	
  on	
  Zend	
  Framework	
  and	
  MySQL	
  
•  Relies	
  heavily	
  on	
  EAV	
  structure	
  
•  XML	
  de^initions	
  
•  Bought	
  by	
  eBay	
  in	
  2011	
  (X.commerce)	
  
•  Current	
  stable	
  version:	
  1.7.0.2	
  
Structure	
  
Templates	
  (1)	
  
Templates	
  (2)	
  
Templates	
  (2)	
  
<block type="page/html“ name="root" output="toHtml“ template="page/3columns.phtml">
<block type="page/html_header" name="header" as="header">
<block type="page/switch" name="store_language" as="store_language"
template="page/switch/languages.phtml"/></block>
</block>
Template: /layout/page.xml
<?php if(count($this->getStores())>1): ?>
<div class="form-language“>
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId())
? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>>
<?php endforeach; ?>
</div>
<?php endif; ?>
Template: /template/page/switch/languages.phtml
Drilling	
  down	
  (1)	
  
Example:
How to get from the article name in
the template to the database field?
Drilling	
  down	
  (2)	
  
1.  Block: <block type="catalog/product_view" name="product.info" template="catalog/
product/view.phtml">
2.  Template: /app/design/frontend/base/default/template/catalog/product/view.phtml
3.  Block class: Mage_Catalog_Block_Product_View
4.  Model: Mage_Catalog_Model_Product:
public function getProduct()
{
if (!Mage::registry('product') && $this->getProductId()) {
$product = Mage::getModel('catalog/product')->load($this->getProductId());
Mage::register('product', $product);
}
return Mage::registry('product');
}
Drilling	
  down	
  (3)	
  
1.  Abstract class: Mage_Core_Model_Abstract
2.  Resource model: Mage_Core_Model_Mysql4_Abstract
public function load($id, $field=null)
{
$this->_beforeLoad($id, $field);
$this->_getResource()->load($this, $id, $field);
$this->_afterLoad();
$this->setOrigData();
$this->_hasDataChanges = false;
return $this;
}
Modules	
  
Brief	
  History	
  
•  OS-­‐Edition	
  since	
  late	
  2008.	
  
•  Based	
  on	
  own	
  PHP-­‐Framework	
  &	
  MySQL	
  
•  Recent	
  version:	
  4.7.3	
  
Features	
  
•  ADODB	
  database	
  abstraction	
  layer	
  
•  Uses	
  Smarty	
  2	
  (but	
  Template	
  Inheritance	
  by	
  
Smarty	
  3)	
  
•  Block	
  Inheritance	
  
•  Autoloader	
  
Structure	
  
Template	
  Inheritance	
  (1)	
  
Template	
  Inheritance	
  (2)	
  
[{capture append="oxidBlock_content"}]
[{assign var="oFirstArticle" value=$oView->getFirstArticle()}]
[{/capture}]
[{include file="layout/page.tpl" sidebar="Right"}]
/out/azure/tpl/page/shop/start.tpl
Template	
  Inheritance	
  (3)	
  
<div id="content">
[{include file="message/errors.tpl"}]
[{foreach from=$oxidBlock_content item="_block"}]
[{$_block}]
[{/foreach}]
</div>
[{include file="layout/footer.tpl"}]
/out/azure/tpl/layout/page.tpl
Drilling	
  down	
  (1)	
  
Example:	
  	
  
How	
  to	
  get	
  from	
  the	
  article	
  name	
  in	
  
the	
  Smarty-­‐Template	
  to	
  the	
  database	
  ^ield?	
  
Drilling	
  down	
  (2)	
  
•  Article	
  detail	
  page:	
  /out/azure/tpl/page/details/inc/productmain.tpl	
  
[{block name="details_productmain_title"}]
<h1 id="productTitle"><span itemprop="name">
[{$oDetailsProduct->oxarticles__oxtitle->value}]
[{$oDetailsProduct->oxarticles__oxvarselect->value}]</span></h1>
[{/block}]
Scheme: [Object name]->[Table name]__[Field name]->value
•  View controller: /application/controller/details.php
Drilling	
  down	
  (3)	
  
public function render()
{
$myConfig = $this->getConfig();
$oProduct = $this->getProduct();
}
public function getProduct()
{
$sOxid = oxConfig::getParameter( 'anid' );
$this->_oProduct = oxNew( 'oxarticle' );
if ( !$this->_oProduct->load( $sOxid ) ) {
...
}
}
Drilling	
  down	
  (4)	
  
public function load( $oxID)
{
$blRet = parent::load( $oxID);
public function load( $sOXID)
{
//getting at least one field before lazy loading the object
$this->_addField('oxid', 0);
$sSelect = $this->buildSelectString( array( $this->getViewName().".oxid" => $sOXID));
return $this->_isLoaded = $this->assignRecord( $sSelect );
}
/application/models/oxarticle.php
/core/oxbase.php
Custom	
  classes	
  (1)	
  
•  Most	
  view-­‐	
  and	
  core	
  classes	
  can	
  be	
  overloaded	
  
•  Module	
  are	
  registered	
  in	
  backend	
  
•  Object	
  instantiation	
  via	
  oxNew():	
  core/oxutilsobject.php	
  
oxArticle
my_oxArticle
our_oxArticle
class my_oxArticle extends oxArticle
class our_oxArticle extends my_oxArticle
Custom	
  classes	
  (2)	
  
•  This	
  procedure	
  becomes	
  problematic	
  when	
  there	
  is	
  more	
  
than	
  one	
  new	
  module	
  wanting	
  to	
  extend	
  a	
  speci^ic	
  class.	
  
•  Solution:	
  oxNew()	
  dynamically	
  creates	
  transparent	
  classes	
  
in	
  the	
  form	
  of:	
  [class-­name]_parent	
  
•  This	
  means	
  that	
  by	
  means	
  of	
  the	
  following	
  structure,	
  module	
  
classes	
  can	
  be	
  chained:	
  
–  oxArticle	
  =>	
  my_oxArticle&our_oxArticle	
  
Plugins	
  (1)	
  
•  Task:	
  Write	
  a	
  module	
  that	
  displays	
  the	
  remaining	
  time	
  until	
  
X	
  mas	
  with	
  each	
  article.	
  
1.  New	
  module	
  directory:	
  /modules/xmas/	
  
2.  Publishing	
  it	
  via	
  metadata.php	
  (used	
  to	
  
be	
  via	
  Admin)	
  
'extend' => array(
'oxarticle' => ‘xmas/xmasArticle'
)
Plugins	
  (2)	
  	
  
class	
  xmasArticle	
  extends	
  xmasArticle_parent	
  
{	
  
	
  	
  	
  	
  public	
  function	
  getDaysLeft()	
  
	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  $time	
  =	
  mktime(0,	
  0,	
  0,	
  12,	
  25,	
  2011,	
  1)	
  -­‐	
  time();	
  
	
  	
  	
  	
  	
  	
  	
  	
  $days	
  =	
  ^loor($time/86400);	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  $days;	
  
	
  	
  	
  	
  }	
  
}	
  
<div>Only [{$oDetailsProduct->getDaysLeft()}] days left until Xmas!</div>
/modules/xmas/xmasArticle.php
/out/azure/tpl/page/details/inc/productmain.tpl
Brief	
  History	
  
•  First	
  stable	
  version	
  released	
  in	
  2007.	
  
•  OS-­‐Edition	
  since	
  October	
  2010.	
  
•  Since	
  v.3.5	
  based	
  on	
  Enlight	
  Framework	
  (based	
  
on	
  ZF)	
  &	
  MySQL	
  
•  MVC-­‐Model	
  
•  Backend	
  based	
  on	
  ExtJS	
  4	
  
•  Templates	
  based	
  on	
  Smarty	
  3	
  
•  Recent	
  version:	
  4.0.7	
  
Enlight-­‐Framework	
  
•  Basis	
  functionalities	
  are	
  inherited	
  from	
  Zend	
  
Framework:	
  	
  
•  Syntax	
  and	
  Work^low	
  
•  Request-­‐	
  and	
  Response-­‐Objects 	
  	
  
•  Action-­‐Controller	
  Design	
  
•  Rewritten	
  Router	
  /	
  Dispatcher	
  and	
  View-­‐
Object	
  optimised	
  for	
  performance	
  and	
  
expandability	
  	
  
•  Own	
  plugin	
  system	
  based	
  on	
  events	
  and	
  hooks	
  
Template-­‐Structure	
  
index.tpl	
  
{* Content section *}
<div id="content">
<div class="inner”>
{* Content top container *}
{block name="frontend_index_content_top"}{/block}
{* Sidebar left *}
{block name='frontend_index_content_left'}
{include file='frontend/index/left.tpl'}
{/block}
{* Main content *}
{block name='frontend_index_content'}{/block}
{* Sidebar right *}
{block name='frontend_index_content_right'}{/block}
<div class="clear">&nbsp;</div>
</div>
</div>
Template-­‐Inheritance	
  
{extends file=”../_default/frontend/home/index.tpl}
{block name=’frontend_index_content’ prepend}
<h1>Hallo Welt</h1>
{/block}
SMARTY:
Append – Prepend - Replace
Plugin-­‐Directory	
  Structure	
  
Drilling	
  down	
  
Example:	
  	
  
How	
  to	
  get	
  from	
  the	
  article	
  name	
  in	
  
the	
  Smarty-­‐Template	
  to	
  the	
  database	
  ^ield?	
  
Drilling	
  down	
  (2)	
  
•  Article	
  detail	
  page:	
  templates_defaultfrontenddetailindex.tpl	
  
•  Part	
  that	
  displays	
  article	
  name	
  in	
  frontend	
  
•  Template-­‐Path	
  (frontend/detail/index.tpl)	
  tells	
  us	
  where	
  to	
  ^ind	
  the	
  
corresponding	
  controller.	
  In	
  this	
  case:	
  Shopware/Controllers/
Frontend/Detail.php	
  –	
  indexAction.	
  
•  Get	
  article	
  information	
  from	
  Model	
  and	
  assign	
  to	
  template	
  
•  Shopware()-­>Modules()-­>Articles()	
  is	
  a	
  service	
  locator	
  to	
  access	
  the	
  
main	
  article	
  object	
  that	
  could	
  be	
  found	
  at	
  /engine/core/class/
sArticles.php	
  	
  
•  sGetArticleById	
  fetches	
  a	
  certain	
  article	
  by	
  id	
  from	
  database	
  and	
  returns	
  
the	
  result	
  as	
  an	
  array	
  for	
  further	
  processing	
  
Plugins:	
  Bootstrap	
  
<?php
class Shopware_Plugins_Frontend_IPCDEMO_Bootstrap
extends Shopware_Components_Plugin_Bootstrap
{
public function install()
{
//
return true;
}
public static function onPostDispatch(Enlight_Event_EventArgs $args)
{
// Still empty
}
}
Plugins:	
  Event	
  
public function install()
{
$event = $this->createEvent('Enlight_Controller_Action_PostDispatch','onPostDispatch');
$this-> subscribeEvent($event);
$form = $this->Form();
$form->setElement('textarea', ’yourtext',
array('label'=>’Text for left column’,'value'=>’Hello World'));
$form->save();
return true;
}
Plugins:	
  Listener	
  
!public static function onPostDispatch(Enlight_Event_EventArgs $args)
{
$view = $args->getSubject()->View();
$config = Shopware()->Plugins()->Frontend()->IPCDEMO()->Config();
$view->pluginText = $config->yourtext;
$view->addTemplateDir(dirname(__FILE__)."/Views/");
$view->extendsTemplate('plugin.tpl');
}
Plugins:	
  Hooks	
  
<?php
class Shopware_Plugins_Frontend_myHook_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
public function install()
{
$hook = $this->createHook(
'sArticles',
'sGetArticleById',
'onArticle',
Enlight_Hook_HookHandler::TypeAfter,
0
);
$this->subscribeHook($hook);
return true;
}
static function onArticle(Enlight_Hook_HookArgs $args)
{
}
}
Summary	
  
• 	
  Each	
  system	
  employs	
  a	
  slightly	
  different	
  method	
  of	
  	
  
	
  	
  	
  inserting	
  custom	
  functionalities	
  
• 	
  Layout	
  and	
  functional	
  ^iles	
  are	
  more	
  or	
  less	
  
encapsulated	
  
• 	
  No	
  core-­‐hacking	
  required	
  –	
  still	
  a	
  need	
  for	
  testing!	
  
Thank	
  you!	
  
Blog:	
  romanzenner.com	
  
Skype:	
  roman_zenner	
  
XING:	
  xing.com/pro^ile/Roman_Zenner	
  
Twitter:	
  twitter.com/rzenner	
  
MVC-­‐Model	
  (extended)	
  

More Related Content

What's hot

Presenting Data Effectively in XPages - ATLUG May 2013
Presenting Data Effectively in XPages - ATLUG May 2013Presenting Data Effectively in XPages - ATLUG May 2013
Presenting Data Effectively in XPages - ATLUG May 2013
balassaitis
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
Fabrizio Giudici
 
Paris Tech Meetup talk : Troubles start at version 1.0
Paris Tech Meetup talk : Troubles start at version 1.0Paris Tech Meetup talk : Troubles start at version 1.0
Paris Tech Meetup talk : Troubles start at version 1.0
Laurent Cerveau
 
JSP - Part 1
JSP - Part 1JSP - Part 1
JSP - Part 1
Hitesh-Java
 
Hibernate - Part 2
Hibernate - Part 2 Hibernate - Part 2
Hibernate - Part 2
Hitesh-Java
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
Deploying Schemas and XMetaL Customization Files
Deploying Schemas and XMetaL Customization FilesDeploying Schemas and XMetaL Customization Files
Deploying Schemas and XMetaL Customization Files
XMetaL
 
JDBC Part - 2
JDBC Part - 2JDBC Part - 2
JDBC Part - 2
Hitesh-Java
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
Talha Ocakçı
 
Java JDBC
Java JDBCJava JDBC
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
WebStackAcademy
 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JS
Ivano Malavolta
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase Integration
WebStackAcademy
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
Mumbai Academisc
 
HTML5 and CSS3 refresher
HTML5 and CSS3 refresherHTML5 and CSS3 refresher
HTML5 and CSS3 refresher
Ivano Malavolta
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
Hicham QAISSI
 
Jdbc api
Jdbc apiJdbc api
Jdbc api
kamal kotecha
 
Internet Explorer 8
Internet Explorer 8Internet Explorer 8
Internet Explorer 8
David Chou
 

What's hot (18)

Presenting Data Effectively in XPages - ATLUG May 2013
Presenting Data Effectively in XPages - ATLUG May 2013Presenting Data Effectively in XPages - ATLUG May 2013
Presenting Data Effectively in XPages - ATLUG May 2013
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
 
Paris Tech Meetup talk : Troubles start at version 1.0
Paris Tech Meetup talk : Troubles start at version 1.0Paris Tech Meetup talk : Troubles start at version 1.0
Paris Tech Meetup talk : Troubles start at version 1.0
 
JSP - Part 1
JSP - Part 1JSP - Part 1
JSP - Part 1
 
Hibernate - Part 2
Hibernate - Part 2 Hibernate - Part 2
Hibernate - Part 2
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Deploying Schemas and XMetaL Customization Files
Deploying Schemas and XMetaL Customization FilesDeploying Schemas and XMetaL Customization Files
Deploying Schemas and XMetaL Customization Files
 
JDBC Part - 2
JDBC Part - 2JDBC Part - 2
JDBC Part - 2
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
 
Java JDBC
Java JDBCJava JDBC
Java JDBC
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JS
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase Integration
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
HTML5 and CSS3 refresher
HTML5 and CSS3 refresherHTML5 and CSS3 refresher
HTML5 and CSS3 refresher
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
 
Jdbc api
Jdbc apiJdbc api
Jdbc api
 
Internet Explorer 8
Internet Explorer 8Internet Explorer 8
Internet Explorer 8
 

Similar to Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)

CodeIgniter & MVC
CodeIgniter & MVCCodeIgniter & MVC
CodeIgniter & MVC
Jamshid Hashimi
 
Magento mega menu extension
Magento mega menu extensionMagento mega menu extension
Magento mega menu extension
Bun Danny
 
Codeinator
CodeinatorCodeinator
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
Ivan Chepurnyi
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
Claudio Procida
 
ExtBase workshop
ExtBase workshop ExtBase workshop
ExtBase workshop
schmutt
 
Backbonejs
BackbonejsBackbonejs
Backbonejs
Knoldus Inc.
 
Intro to Drupal Module Developement
Intro to Drupal Module DevelopementIntro to Drupal Module Developement
Intro to Drupal Module Developement
Matt Mendonca
 
AngularJS
AngularJSAngularJS
AngularJS
Yogesh L
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
Joram Salinas
 
Dexterity in the Wild
Dexterity in the WildDexterity in the Wild
Dexterity in the Wild
David Glick
 
Library management system
Library management systemLibrary management system
Library management system
siddiqui241993
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
VO Tho
 
Math-Bridge Architecture
Math-Bridge ArchitectureMath-Bridge Architecture
Math-Bridge Architecture
metamath
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
Nerd Tzanetopoulos
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
Azilen Technologies Pvt. Ltd.
 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"
LogeekNightUkraine
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
Rachit Gupta
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 

Similar to Modul-Entwicklung für Magento, OXID eShop und Shopware (2013) (20)

CodeIgniter & MVC
CodeIgniter & MVCCodeIgniter & MVC
CodeIgniter & MVC
 
Magento mega menu extension
Magento mega menu extensionMagento mega menu extension
Magento mega menu extension
 
Codeinator
CodeinatorCodeinator
Codeinator
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
 
ExtBase workshop
ExtBase workshop ExtBase workshop
ExtBase workshop
 
Backbonejs
BackbonejsBackbonejs
Backbonejs
 
Intro to Drupal Module Developement
Intro to Drupal Module DevelopementIntro to Drupal Module Developement
Intro to Drupal Module Developement
 
AngularJS
AngularJSAngularJS
AngularJS
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Dexterity in the Wild
Dexterity in the WildDexterity in the Wild
Dexterity in the Wild
 
Library management system
Library management systemLibrary management system
Library management system
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Math-Bridge Architecture
Math-Bridge ArchitectureMath-Bridge Architecture
Math-Bridge Architecture
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 

More from Roman Zenner

Daten in Online-Shops: Personalisierung & die Freaky Line (2014)
Daten in Online-Shops: Personalisierung & die Freaky Line (2014)Daten in Online-Shops: Personalisierung & die Freaky Line (2014)
Daten in Online-Shops: Personalisierung & die Freaky Line (2014)
Roman Zenner
 
KPIs für den E-Commerce (2014)
KPIs für den E-Commerce (2014)KPIs für den E-Commerce (2014)
KPIs für den E-Commerce (2014)
Roman Zenner
 
E-Commerce: Wachstumspotentiale erkennen und nutzen (2013)
E-Commerce: Wachstumspotentiale erkennen und nutzen (2013)E-Commerce: Wachstumspotentiale erkennen und nutzen (2013)
E-Commerce: Wachstumspotentiale erkennen und nutzen (2013)
Roman Zenner
 
Die Herausforderung der Einführung einer Multi-Channel-Strategie am Beispiel ...
Die Herausforderung der Einführung einer Multi-Channel-Strategie am Beispiel ...Die Herausforderung der Einführung einer Multi-Channel-Strategie am Beispiel ...
Die Herausforderung der Einführung einer Multi-Channel-Strategie am Beispiel ...
Roman Zenner
 
Curated Commerce (2014)
Curated Commerce (2014)Curated Commerce (2014)
Curated Commerce (2014)
Roman Zenner
 
... das muss doch einfacher gehen (2013)
... das muss doch einfacher gehen (2013)... das muss doch einfacher gehen (2013)
... das muss doch einfacher gehen (2013)
Roman Zenner
 
Neue Trends im E-Commerce (2011)
Neue Trends im E-Commerce (2011)Neue Trends im E-Commerce (2011)
Neue Trends im E-Commerce (2011)
Roman Zenner
 
Wie wählt man das richtige Shopsystem? (2012)
Wie wählt man das richtige Shopsystem? (2012)Wie wählt man das richtige Shopsystem? (2012)
Wie wählt man das richtige Shopsystem? (2012)
Roman Zenner
 
Github is from Venus, Excel is from Mars: Wie sich Entwickler und Business-En...
Github is from Venus, Excel is from Mars: Wie sich Entwickler und Business-En...Github is from Venus, Excel is from Mars: Wie sich Entwickler und Business-En...
Github is from Venus, Excel is from Mars: Wie sich Entwickler und Business-En...
Roman Zenner
 
Commerce im Wandel: Steine, Schweine - und immer an die Leser denken!
Commerce im Wandel: Steine, Schweine - und immer an die Leser denken!Commerce im Wandel: Steine, Schweine - und immer an die Leser denken!
Commerce im Wandel: Steine, Schweine - und immer an die Leser denken!
Roman Zenner
 
Mobile Commerce (Meet-Magento 04.10)
Mobile Commerce (Meet-Magento 04.10)Mobile Commerce (Meet-Magento 04.10)
Mobile Commerce (Meet-Magento 04.10)
Roman Zenner
 
Magento-Schnittstellen
Magento-SchnittstellenMagento-Schnittstellen
Magento-Schnittstellen
Roman Zenner
 

More from Roman Zenner (12)

Daten in Online-Shops: Personalisierung & die Freaky Line (2014)
Daten in Online-Shops: Personalisierung & die Freaky Line (2014)Daten in Online-Shops: Personalisierung & die Freaky Line (2014)
Daten in Online-Shops: Personalisierung & die Freaky Line (2014)
 
KPIs für den E-Commerce (2014)
KPIs für den E-Commerce (2014)KPIs für den E-Commerce (2014)
KPIs für den E-Commerce (2014)
 
E-Commerce: Wachstumspotentiale erkennen und nutzen (2013)
E-Commerce: Wachstumspotentiale erkennen und nutzen (2013)E-Commerce: Wachstumspotentiale erkennen und nutzen (2013)
E-Commerce: Wachstumspotentiale erkennen und nutzen (2013)
 
Die Herausforderung der Einführung einer Multi-Channel-Strategie am Beispiel ...
Die Herausforderung der Einführung einer Multi-Channel-Strategie am Beispiel ...Die Herausforderung der Einführung einer Multi-Channel-Strategie am Beispiel ...
Die Herausforderung der Einführung einer Multi-Channel-Strategie am Beispiel ...
 
Curated Commerce (2014)
Curated Commerce (2014)Curated Commerce (2014)
Curated Commerce (2014)
 
... das muss doch einfacher gehen (2013)
... das muss doch einfacher gehen (2013)... das muss doch einfacher gehen (2013)
... das muss doch einfacher gehen (2013)
 
Neue Trends im E-Commerce (2011)
Neue Trends im E-Commerce (2011)Neue Trends im E-Commerce (2011)
Neue Trends im E-Commerce (2011)
 
Wie wählt man das richtige Shopsystem? (2012)
Wie wählt man das richtige Shopsystem? (2012)Wie wählt man das richtige Shopsystem? (2012)
Wie wählt man das richtige Shopsystem? (2012)
 
Github is from Venus, Excel is from Mars: Wie sich Entwickler und Business-En...
Github is from Venus, Excel is from Mars: Wie sich Entwickler und Business-En...Github is from Venus, Excel is from Mars: Wie sich Entwickler und Business-En...
Github is from Venus, Excel is from Mars: Wie sich Entwickler und Business-En...
 
Commerce im Wandel: Steine, Schweine - und immer an die Leser denken!
Commerce im Wandel: Steine, Schweine - und immer an die Leser denken!Commerce im Wandel: Steine, Schweine - und immer an die Leser denken!
Commerce im Wandel: Steine, Schweine - und immer an die Leser denken!
 
Mobile Commerce (Meet-Magento 04.10)
Mobile Commerce (Meet-Magento 04.10)Mobile Commerce (Meet-Magento 04.10)
Mobile Commerce (Meet-Magento 04.10)
 
Magento-Schnittstellen
Magento-SchnittstellenMagento-Schnittstellen
Magento-Schnittstellen
 

Recently uploaded

快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
3a0sd7z3
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
thezot
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
3a0sd7z3
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
xjq03c34
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
k4ncd0z
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
Tarandeep Singh
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
davidjhones387
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
Donato Onofri
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
rtunex8r
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
APNIC
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
APNIC
 

Recently uploaded (12)

快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
 

Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)

  • 1. How  to  write  Custom   Modules  for  PHP-­based  E-­ Commerce  Systems   Roman  Z.  
  • 2. Roman  Zenner   •  Working  as  freelance  trainer,  author  and   consultant  since  2004   •  Has  written  three  books  on  Magento  and   OXID  eShop   •  Is  in  the  process  of  writing  a  “cookbook”   on  OXID  eShop  with  Joscha  Krug   •  Publishes  in  various  magazines  
  • 3. Initial  thoughts   •  Modularity  a  no-­‐brainer  in  today’s   ecommerce  software   •  There  must  be  a  way  of  extending  classes   or  an  event-­‐listener  system  in  order  to   integrate  custom  functionalities  
  • 4. Types  of  modules   •  Encapsulate  graphical  (template)   changes   •  Provide  additional  information  (e.g.  for   an  article   •  Special  calculations   •  Payment  and  shipping   •  Other  interfaces  (ImpEx,  etc.)  
  • 5. Today‘s  candidates   •  Magento   •  OXID  eShop   •  Shopware  
  • 7.
  • 8. Brief  History   •  First  stable  version  released  in  spring  2008   •  Community  Edition  under  OSL   •  Professional  and  Enterprise  Editions   •  Based  on  Zend  Framework  and  MySQL   •  Relies  heavily  on  EAV  structure   •  XML  de^initions   •  Bought  by  eBay  in  2011  (X.commerce)   •  Current  stable  version:  1.7.0.2  
  • 12. Templates  (2)   <block type="page/html“ name="root" output="toHtml“ template="page/3columns.phtml"> <block type="page/html_header" name="header" as="header"> <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/></block> </block> Template: /layout/page.xml <?php if(count($this->getStores())>1): ?> <div class="form-language“> <?php foreach ($this->getStores() as $_lang): ?> <?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?> <option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>> <?php endforeach; ?> </div> <?php endif; ?> Template: /template/page/switch/languages.phtml
  • 13. Drilling  down  (1)   Example: How to get from the article name in the template to the database field?
  • 14. Drilling  down  (2)   1.  Block: <block type="catalog/product_view" name="product.info" template="catalog/ product/view.phtml"> 2.  Template: /app/design/frontend/base/default/template/catalog/product/view.phtml 3.  Block class: Mage_Catalog_Block_Product_View 4.  Model: Mage_Catalog_Model_Product: public function getProduct() { if (!Mage::registry('product') && $this->getProductId()) { $product = Mage::getModel('catalog/product')->load($this->getProductId()); Mage::register('product', $product); } return Mage::registry('product'); }
  • 15. Drilling  down  (3)   1.  Abstract class: Mage_Core_Model_Abstract 2.  Resource model: Mage_Core_Model_Mysql4_Abstract public function load($id, $field=null) { $this->_beforeLoad($id, $field); $this->_getResource()->load($this, $id, $field); $this->_afterLoad(); $this->setOrigData(); $this->_hasDataChanges = false; return $this; }
  • 17.
  • 18. Brief  History   •  OS-­‐Edition  since  late  2008.   •  Based  on  own  PHP-­‐Framework  &  MySQL   •  Recent  version:  4.7.3  
  • 19. Features   •  ADODB  database  abstraction  layer   •  Uses  Smarty  2  (but  Template  Inheritance  by   Smarty  3)   •  Block  Inheritance   •  Autoloader  
  • 22. Template  Inheritance  (2)   [{capture append="oxidBlock_content"}] [{assign var="oFirstArticle" value=$oView->getFirstArticle()}] [{/capture}] [{include file="layout/page.tpl" sidebar="Right"}] /out/azure/tpl/page/shop/start.tpl
  • 23. Template  Inheritance  (3)   <div id="content"> [{include file="message/errors.tpl"}] [{foreach from=$oxidBlock_content item="_block"}] [{$_block}] [{/foreach}] </div> [{include file="layout/footer.tpl"}] /out/azure/tpl/layout/page.tpl
  • 24. Drilling  down  (1)   Example:     How  to  get  from  the  article  name  in   the  Smarty-­‐Template  to  the  database  ^ield?  
  • 25. Drilling  down  (2)   •  Article  detail  page:  /out/azure/tpl/page/details/inc/productmain.tpl   [{block name="details_productmain_title"}] <h1 id="productTitle"><span itemprop="name"> [{$oDetailsProduct->oxarticles__oxtitle->value}] [{$oDetailsProduct->oxarticles__oxvarselect->value}]</span></h1> [{/block}] Scheme: [Object name]->[Table name]__[Field name]->value •  View controller: /application/controller/details.php
  • 26. Drilling  down  (3)   public function render() { $myConfig = $this->getConfig(); $oProduct = $this->getProduct(); } public function getProduct() { $sOxid = oxConfig::getParameter( 'anid' ); $this->_oProduct = oxNew( 'oxarticle' ); if ( !$this->_oProduct->load( $sOxid ) ) { ... } }
  • 27. Drilling  down  (4)   public function load( $oxID) { $blRet = parent::load( $oxID); public function load( $sOXID) { //getting at least one field before lazy loading the object $this->_addField('oxid', 0); $sSelect = $this->buildSelectString( array( $this->getViewName().".oxid" => $sOXID)); return $this->_isLoaded = $this->assignRecord( $sSelect ); } /application/models/oxarticle.php /core/oxbase.php
  • 28. Custom  classes  (1)   •  Most  view-­‐  and  core  classes  can  be  overloaded   •  Module  are  registered  in  backend   •  Object  instantiation  via  oxNew():  core/oxutilsobject.php   oxArticle my_oxArticle our_oxArticle class my_oxArticle extends oxArticle class our_oxArticle extends my_oxArticle
  • 29. Custom  classes  (2)   •  This  procedure  becomes  problematic  when  there  is  more   than  one  new  module  wanting  to  extend  a  speci^ic  class.   •  Solution:  oxNew()  dynamically  creates  transparent  classes   in  the  form  of:  [class-­name]_parent   •  This  means  that  by  means  of  the  following  structure,  module   classes  can  be  chained:   –  oxArticle  =>  my_oxArticle&our_oxArticle  
  • 30. Plugins  (1)   •  Task:  Write  a  module  that  displays  the  remaining  time  until   X  mas  with  each  article.   1.  New  module  directory:  /modules/xmas/   2.  Publishing  it  via  metadata.php  (used  to   be  via  Admin)   'extend' => array( 'oxarticle' => ‘xmas/xmasArticle' )
  • 31. Plugins  (2)     class  xmasArticle  extends  xmasArticle_parent   {          public  function  getDaysLeft()          {                  $time  =  mktime(0,  0,  0,  12,  25,  2011,  1)  -­‐  time();                  $days  =  ^loor($time/86400);                  return  $days;          }   }   <div>Only [{$oDetailsProduct->getDaysLeft()}] days left until Xmas!</div> /modules/xmas/xmasArticle.php /out/azure/tpl/page/details/inc/productmain.tpl
  • 32.
  • 33. Brief  History   •  First  stable  version  released  in  2007.   •  OS-­‐Edition  since  October  2010.   •  Since  v.3.5  based  on  Enlight  Framework  (based   on  ZF)  &  MySQL   •  MVC-­‐Model   •  Backend  based  on  ExtJS  4   •  Templates  based  on  Smarty  3   •  Recent  version:  4.0.7  
  • 34. Enlight-­‐Framework   •  Basis  functionalities  are  inherited  from  Zend   Framework:     •  Syntax  and  Work^low   •  Request-­‐  and  Response-­‐Objects     •  Action-­‐Controller  Design   •  Rewritten  Router  /  Dispatcher  and  View-­‐ Object  optimised  for  performance  and   expandability     •  Own  plugin  system  based  on  events  and  hooks  
  • 36. index.tpl   {* Content section *} <div id="content"> <div class="inner”> {* Content top container *} {block name="frontend_index_content_top"}{/block} {* Sidebar left *} {block name='frontend_index_content_left'} {include file='frontend/index/left.tpl'} {/block} {* Main content *} {block name='frontend_index_content'}{/block} {* Sidebar right *} {block name='frontend_index_content_right'}{/block} <div class="clear">&nbsp;</div> </div> </div>
  • 37. Template-­‐Inheritance   {extends file=”../_default/frontend/home/index.tpl} {block name=’frontend_index_content’ prepend} <h1>Hallo Welt</h1> {/block} SMARTY: Append – Prepend - Replace
  • 39. Drilling  down   Example:     How  to  get  from  the  article  name  in   the  Smarty-­‐Template  to  the  database  ^ield?  
  • 40. Drilling  down  (2)   •  Article  detail  page:  templates_defaultfrontenddetailindex.tpl   •  Part  that  displays  article  name  in  frontend   •  Template-­‐Path  (frontend/detail/index.tpl)  tells  us  where  to  ^ind  the   corresponding  controller.  In  this  case:  Shopware/Controllers/ Frontend/Detail.php  –  indexAction.   •  Get  article  information  from  Model  and  assign  to  template   •  Shopware()-­>Modules()-­>Articles()  is  a  service  locator  to  access  the   main  article  object  that  could  be  found  at  /engine/core/class/ sArticles.php     •  sGetArticleById  fetches  a  certain  article  by  id  from  database  and  returns   the  result  as  an  array  for  further  processing  
  • 41. Plugins:  Bootstrap   <?php class Shopware_Plugins_Frontend_IPCDEMO_Bootstrap extends Shopware_Components_Plugin_Bootstrap { public function install() { // return true; } public static function onPostDispatch(Enlight_Event_EventArgs $args) { // Still empty } }
  • 42. Plugins:  Event   public function install() { $event = $this->createEvent('Enlight_Controller_Action_PostDispatch','onPostDispatch'); $this-> subscribeEvent($event); $form = $this->Form(); $form->setElement('textarea', ’yourtext', array('label'=>’Text for left column’,'value'=>’Hello World')); $form->save(); return true; }
  • 43. Plugins:  Listener   !public static function onPostDispatch(Enlight_Event_EventArgs $args) { $view = $args->getSubject()->View(); $config = Shopware()->Plugins()->Frontend()->IPCDEMO()->Config(); $view->pluginText = $config->yourtext; $view->addTemplateDir(dirname(__FILE__)."/Views/"); $view->extendsTemplate('plugin.tpl'); }
  • 44. Plugins:  Hooks   <?php class Shopware_Plugins_Frontend_myHook_Bootstrap extends Shopware_Components_Plugin_Bootstrap { public function install() { $hook = $this->createHook( 'sArticles', 'sGetArticleById', 'onArticle', Enlight_Hook_HookHandler::TypeAfter, 0 ); $this->subscribeHook($hook); return true; } static function onArticle(Enlight_Hook_HookArgs $args) { } }
  • 45. Summary   •   Each  system  employs  a  slightly  different  method  of          inserting  custom  functionalities   •   Layout  and  functional  ^iles  are  more  or  less   encapsulated   •   No  core-­‐hacking  required  –  still  a  need  for  testing!  
  • 46. Thank  you!   Blog:  romanzenner.com   Skype:  roman_zenner   XING:  xing.com/pro^ile/Roman_Zenner   Twitter:  twitter.com/rzenner