Magento Certified Developer What, Why & How
Click to edit Master title style Click to edit Master text styles What is it?
A brief review (March 2008 November 2012)
1.0-1.3 If it works, it s okay (go on, hack the core)
CE 1.4-1.5 / EE 1.6-1.10 Put everything into modules (rewrite conflicts, messy themes)
CE 1.6 / EE 1.11 (Guess) best practices (upgradability, compatibility, accountability)
CE 1.7 / EE 1.12 Create quality code (confirmed best practices, functional & integration testing)
December 2011
Created by advisory board Industry best practices Launched Dec. 2011 Currently based on Magento 1.5.1.0
Two options Magento Certified Developer Magento Certified Developer Plus
Prove you are certified! http://www.magento.com/certification/directory/
Prove you are certified! http://www.magento.com/certification/directory/
Association with a Solution Partner
Why?
Learn the right way to accomplish things
Employers prefer Magento Certified Developers
Higher wages compared to non-certified developers
Solution Partners: Stand out through number of certified developers
How?
Study Guide Promotes self-study Lists exam content areas Questions to guide studying Pointers into the codebase for finding answers
Moderator Kit Social learning Objectives organized into 11 sections 12 meetings Homework exercises Timelines, sample solutions & guides
Logistics Available at any testing center worldwide Time 90 minutes (MCD) 120 minutes (MCD Plus) Waiting period after a failed attempt (15 days first, 90 thereafter)
Steps to take Go to http://magento.com/certification/ 1. Purchase an exam voucher 2. Find a testing center 3. Register to take the exam 4. Take the exam
And now, on to the fun part!
... [transition to technical content]...
... [take a breath & please sit comfortably]...
Adminhtml Field Renderers
Renderers put elements in context Renderer
Adminhtml Widget Forms
System Configuration Forms
Adminhtml Widget Form Fields
Adding a field to an adminhtml form protected function _prepareform() { $form = new Varien_Data_Form(); $this->setform($form); } $fieldset = $form->addfieldset('fieldset1', array( 'legend' => 'Example Fieldset' )); $fieldset->addfield('field1', 'select', array( 'name' => 'example2', 'label' => 'A Select Field', 'options' => array('', 'A', 'B', 'C') )); return parent::_prepareform();
Defaults are set in adminhtml/widget_form protected function _preparelayout() { Varien_Data_Form::setElementRenderer( $this->getlayout()->createblock('adminhtml/widget_form_renderer_element') ); Varien_Data_Form::setFieldsetRenderer( $this->getlayout()->createblock('adminhtml/widget_form_renderer_fieldset') ); Varien_Data_Form::setFieldsetElementRenderer( $this->getlayout()->createblock('adminhtml/widget_form_renderer_fieldset_element') ); } return parent::_preparelayout();
protected function _prepareform() { $form = new Varien_Data_Form(); $this->setform($form); $field1 = $form->addfield('example1', 'text', array( 'name' => 'example1', 'label' => 'Field w/o Fieldset', )); $fieldset = $form->addfieldset('fieldset1', array( 'legend' => 'Example Fieldset' )); $field2 = $fieldset->addfield('example2', 'text', array( 'name' => 'example2', 'label' => 'Field with Fieldset' )); adminhtml/widget_form_renderer_element adminhtml/widget_form_renderer_fieldset adminhtml/widget_form_renderer_fieldset_element
Setting a custom renderer protected function _prepareform() { $form = new Varien_Data_Form(); $this->setform($form); } $fieldset = $form->addfieldset('fieldset1', array( 'legend' => 'Example Fieldset' )); $field = $fieldset->addfield('field1', 'select', array( 'name' => 'example2', 'label' => 'A Select Field', 'options' => array('', 'A', 'B', 'C'), 'renderer' => magento_live/adminhtml_form_example_field_renderer' )); return parent::_prepareform();
Renderer interface class Magento_Live_Block_Adminhtml_Form_Example_Field_Renderer extends Mage_Adminhtml_Block_Template implements Varien_Data_Form_Element_Renderer_Interface { protected function _construct() { $this->settemplate( magento/live/form/field/renderer/example.phtml'); } } public function render(varien_data_form_element_abstract $element) { $this->setelement($element); return $this->tohtml(); }
System Configuration Fields
System configuration Default field renderer: adminhtml/system_config_form_field Set in: adminhtml/system_config_form
Custom system configuration field renderer <!-- system.xml --> <fields> <renderer_example> <label>a Custom Renderer</label> <!-- Specify the renderer (a block class): --> <frontend_model>magento_live/adminhtml_system_config_custom</frontend_model> <sort_order>10</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </renderer_example> </fields> <!--... -->
Custom system configuration field renderer class Magento_Live_Block_Adminhtml_System_Config_Custom extends Mage_Adminhtml_Block_System_Config_Form_Field { public function render(varien_data_form_element_abstract $element) { $element->setscope(false); // example customization return parent::render($element); } } protected function _getelementhtml(varien_data_form_element_abstract $element) { return $this->getlayout()->createblock('core/template', $element->getid(). '_tmp') ->settemplate( magento/live/system/config/custom.phtml') ->setelement($element)->tohtml(); }
In the template access element properties $this->getelement()->getlabelhtml() $this->getelement()->getelementhtml() $this->getelement()->getname()
...that was the warm-up, on to part two...
Payment Flow
Some basic prerequisites
Onepage checkout Multiaddress checkout
Payment Method Process payment transactions identified by unique code model specified in global/payment/$code/model extend Mage_Payment_Model_Method_Abstract Payment Information Store Transaction Data sales/quote_payment sales/order_payment
Payment Method getmethodinstance() getinfoinstance() Payment Info
Payment Actions Authorize Reserve funds on card, capture or release later Capture Void Capture authorized the funds using token or id from authorize. Usually called when shipping items. Implementation specific. For example, release authorized funds, or void the whole payment. Creditmemo Synonym for refund. Only applicable to captured payments.
Order state & order status State A Status A1 Status A2 State B Status B1 Status C1 State C Status C2 Status C3
Order states Create Order STATE_NEW or STATE_PENDING_PAYMENT Invoiced Shipped STATE_PROCESSING or STATE_PENDING_REVIEW Invoiced && Shipped STATE_COMPLETE Refunded STATE_CLOSED
Communication with external payment providers Customer Customer Customer Magento Host Magento Host Payment Provider Payment Provider Magento Host
Prerequisites? Check
Here is the flow...
Onepage checkout/type_onepage ::saveorder() sales/service_quote ::submitall() ::submitorder() Multishipping checkout/type_multishipping ::createorders() sales/order ::place() ::_placepayment() sales/order_payment ::place() payment flow control logic Customer Magento Host Customer Magento Host Payment Provider
sales/order_payment ::place() if isinitializeneeded() == true protected $_isinitializeneeded $methodinstance->initialize( $methodinstance->getconfigdata('payment_action'), $stateobject // Varien_Object Instance ); $methodinstance->initialize() Order State: $stateobject->getstate() Order Status: $stateobject->getstatus() Customer Magento Host Payment Provider
sales/order_payment ::place() if isinitializeneeded() == false protected $_isinitializeneeded public function getconfigdata($field, $storeid = null) { $path = 'payment/'.$this->getcode().'/'.$field; return Mage::getStoreConfig($path, $storeid); } payment method instance ::getconfigdata('payment_action') not set? Order State: NEW Order Status: getconfigdata('order_status') or, if not set, PENDING Customer Magento Host
sales/order_payment ::place() if isinitializeneeded() == false protected $_isinitializeneeded payment method instance ::getconfigdata('payment_action') order Mage_Payment_Model_Method_Abstract::ACTION_ORDER authorize Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE authorize_capture Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE possible return values besides null? Customer Magento Host Payment Provider
sales/order_payment ::place() payment method instance ::getconfigdata('payment_action') order $infoinstance->_order() authorize $infoinstance->_authorize() authorize_capture $infoinstance->capture() Customer Magento Host Payment Provider
getconfigdata('payment_action') == 'order' isinitializeneeded() == false sales/order_payment ::_order($order->getbasetotaldue()) payment method instance ::order($infoinstance, $amount) Payment hook method implement as needed public function order(varien_object $payment, $amount) { return $this; } Order State: PROCESSING or PAYMENT_REVIEW Order Status: $methodinstance->getconfigdata('order_status') Customer Magento Host Payment Provider
getconfigdata('payment_action') == 'authorize' isinitializeneeded() == false sales/order_payment ::_authorize($order->getbasetotaldue()) payment method instance ::authorize($infoinstance, $amount) Payment hook method implement as needed public function authorize(varien_object $payment, $amount) { return $this; } Order State: PROCESSING or PAYMENT_REVIEW Order Status: $methodinstance->getconfigdata('order_status') Customer Magento Host Payment Provider
'order' is not different from the 'authorize' except for the method names Customer Magento Host Payment Provider
Invoice creation getconfigdata('payment_action') == 'authorize_capture' isinitializeneeded() == false sales/order_payment ::capture(null) payment method instance ::capture($infoinstance, $amount) sales/order ::prepareinvoice() sales/order_invoice ::capture() sales/order_payment ::capture($invoice) sales/order_invoice ::pay() Order State: PROCESSING or PAYMENT_REVIEW Order Status: $methodinstance->getconfigdata('order_status') Customer Magento Host Payment Provider
How about payments via redirect? Customer Payment Provider Magento Host
Redirects are not supported by checkout/type_multishipping Customer Payment Provider Magento Host
Redirects are supported by checkout/type_onepage Customer Payment Provider Magento Host
Option one: Redirect after the customer selects the payment method. Mage_Checkout_OnepageController ::savepaymentaction() sales/quote_payment ::getcheckoutredirecturl() payment method instance ::getcheckoutredirecturl() No order is created before the redirect Create order after the customer is returned Customer Payment Provider Magento Host
Option one: Redirect after the the review order step. Mage_Checkout_OnepageController ::savepaymentaction() sales/quote_payment ::getcheckoutredirecturl() payment method instance ::getcheckoutredirecturl() Order was created before the redirect sales/order::place() was called() Update order after customer is returned Customer Payment Provider Magento Host
And what about the payment related data?
Payment data handling checkout/type_onepage ::savepayment() sales/quote_payment ::importdata($data) payment method instance ::assigndata($data) Persist data sales/quote_payment ::adddata($data) sales/(quote order)_payment ::setadditionalinformation($key, $value)
Payment flow summary Configure <model>, <active> and <payment_action> config nodes Create model, implement payment hook methods as needed initialize() authorize() capture() getcheckoutredirecturl() getorderplaceredirecturl() assigndata() For redirect payments implement controller and view layer logic
Certification Exam Study Guide PDF Study Group Moderator Kit http://www.magento.com/certification Magento U Training Fundamentals of Magento Development (on demand or classroom) Quickstart to Magento Customization (on demand) Checkout Series (online instructor lead) http://www.magento.com/training
Study take the test pass! Questions? Twitter @VinaiKopp