Magento Certified Developerinfo2.magento.com/rs/magentoenterprise/images...• Created by advisory...

74

Transcript of Magento Certified Developerinfo2.magento.com/rs/magentoenterprise/images...• Created by advisory...

  • 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

    A Custom Renderer magento_live/adminhtml_system_config_custom 10 1 1 1

  • 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 Payment Information

    Process payment transactions

    • identified by unique code

    • model specified in global/payment/$code/model

    • extend Mage_Payment_Model_Method_Abstract

    Store Transaction Data

    • sales/quote_payment

    • sales/order_payment

  • Payment Method

    Payment Info

    getInfoInstance() getMethodInstance()

  • Payment Actions

    Authorize

    Capture

    Void

    Creditmemo

    Reserve funds on card, capture or release later

    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.

    Synonym for refund. Only applicable to captured payments.

  • Order state & order status

    State A Status A1

    Status A2 State B Status B1

    State C

    Status C1

    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 Magento

    Host

    Customer Magento

    Host Payment Provider

    Customer Payment Provider

    Magento Host

  • Prerequisites? Check √

  • Here is the flow...

  • Multishipping Onepage

    checkout/type_onepage ::saveOrder()

    sales/service_quote ::submitAll()

    ::submitOrder()

    sales/order ::place()

    ::_placePayment()

    checkout/type_multishipping ::createOrders()

    sales/order_payment ::place()

    payment flow control logic

    Customer Magento

    Host

    Customer Magento

    Host Payment Provider

  • sales/order_payment ::place()

    Customer Magento

    Host Payment Provider

    if isInitializeNeeded() == true protected $_isInitializeNeeded

    Order State: $stateObject->getState()

    Order Status:

    $stateObject->getStatus()

    $methodInstance->initialize( $methodInstance->getConfigData('payment_action'), $stateObject // Varien_Object Instance );

    $methodInstance->initialize()

  • Order State: NEW

    Order Status: getConfigData('order_status')

    or, if not set, PENDING

    sales/order_payment ::place()

    payment method instance ::getConfigData('payment_action')

    not set?

    public function getConfigData($field, $storeId = null) { $path = 'payment/'.$this->getCode().'/'.$field; return Mage::getStoreConfig($path, $storeId); }

    Customer Magento

    Host

    if isInitializeNeeded() == false protected $_isInitializeNeeded

  • Customer Magento

    Host Payment Provider

    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

    sales/order_payment ::place()

    payment method instance ::getConfigData('payment_action')

    possible return values besides null?

    if isInitializeNeeded() == false protected $_isInitializeNeeded

  • Customer Magento

    Host Payment Provider

    sales/order_payment ::place()

    order

    authorize

    authorize_capture

    $infoInstance->_order()

    $infoInstance->_authorize()

    $infoInstance->capture()

    payment method instance ::getConfigData('payment_action')

  • 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

    sales/order_payment ::capture(null)

    sales/order ::prepareInvoice()

    sales/order_invoice ::capture()

    sales/order_payment ::capture($invoice)

    payment method instance ::capture($infoInstance, $amount)

    Order State: PROCESSING or PAYMENT_REVIEW

    Order Status: $methodInstance->getConfigData('order_status')

    sales/order_invoice ::pay()

    Invo

    ice

    crea

    tio

    n

    • getConfigData('payment_action') == 'authorize_capture' • isInitializeNeeded() == false

  • How about payments via redirect?

    Customer Payment Provider

    Magento Host

  • 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

  • And what about the payment related data?

  • Payment data handling

    checkout/type_onepage ::savePayment()

    sales/quote_payment ::importData($data)

    payment method instance ::assignData($data)

    sales/quote_payment ::addData($data)

    sales/(quote|order)_payment ::setAdditionalInformation($key, $value)

    Persist data

  • Payment flow summary • Configure , and 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