Magento Developer Certification Preparation Study Group

Session Four

Andreas Mautz || @mautz_et_tong

webvisum GmbH

NACH RECHTS
Neue Location? Oder hier OK?

Was?

ORM, Database, Setup Script

NACH UNTEN
ORM, Database, Setup Script

Wer?

  • Andreas Mautz
  • programmiert seit 16 Jahren
  • macht magento seit 2008
  • beschäftigt sich mit Deployment-Prozessen, Entwicklungsinfrastrukturen und Wissensmanagement seit 2011
  • Vorbereitung Zertifizierung
  • Lehren und Lernen Stoff zusammenzufassen
NACH UNTEN

Locationcation

brandung

Next: ???

NACH RECHTS

Ablauf

Was machen wir denn heute Schönes?

  • Hausaufgaben besprechen
  • ORM
  • Datenbank
  • Setup Scripts
  • neue Aufgaben
  • Sonstiges
NACH RECHTS
  • Hausaufgaben besprechen
  • ORM
  • Datenbank
  • Setup Scripts
  • neue Aufgaben
  • Sonstiges
Reminder: Dev-Entwicklung mitbringen, wenn ihr Fragen habt Unterlagen mitbringen

Hausaufgaben!

In a custom action controller, render only the contents of a single custom update handle.

Rewrite the breadcrumbs block and add a hardcoded crumb at the beginning without modifying the template. Note: Do not use the _toHtml() method to implement this customization.

Create a frontend widget with a JavaScript color picker form element and image upload functionality in the widget form. When rendering, the widget displays the image with a border of the chosen color.

NACH UNTEN
Jemand vorstellen? Probleme? Fragen? Straight: 15 Minuten CUT!

ORM | Begriffserklärung

  • ORM (Object Relational Mapping)
  • model
  • resource model
  • collection model
NACH UNTEN
A “model” is used to store data, and perhaps performs some business logics against that data.
A “resource model” is used to interact with the database on behalf of the “model”. The “resource model” actually performs the CRUD operations.
A “collection model” holds from one to many “models” and knows how to tell the “resource model” to get rows in the basis of information it is given.
There’s a basic ActiveRecord-like/one-object-one-table Model, and there’s also an Entity Attribute Value (EAV) Model.
http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-5-magento-models-and-orm-basics

Datenbanken

database connection

            
                
                    
                        Mage_Cert
                        core_setup
                    
                    
                        core_write
                    
                    
                        core_read
                    
                
            
        

Datenbanken

basic operations

  • $model->getData();
  • $model->getData('title');
  • $model->getOrigData();
  • $model->getOrigData('title');
  • $model->getModelId();
  • $model->setModelId(42);
  • $model->unsetModelId();
  • if($model->hasModelId()){...}
NACH UNTEN
http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-5-magento-models-and-orm-basics

Datenbanken

CRUD

  • $model = Mage::getModel('foo/bar');
  • $model->load(ID);
  • $model->setFnord("Data String");
  • $model->save();
  • -----
  • $model->delete();
NACH UNTEN
http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-5-magento-models-and-orm-basics

Datenbanken

Collections

  • grouped operations
  • filtering
  • sorting
NACH UNTEN
http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-5-magento-models-and-orm-basics

Setup Scripte

  • sql-Datei
  • Versionierungsstruktur

Setup Scripte

            $installer = $this;
$installer->startSetup();
$installer->run("SQL HIER");
$installer->endSetup();
        
NACH UNTEN
http://blog.magestore.com/2012/03/09/magento-certificate-installupgrade-scripts/ http://www.codegento.com/2011/02/altering-the-database-through-setup-scripts/

neue Hausaufgaben!

für Session 6:

Create a custom entity table for comments using a setup script.

Create a comments entity model, flat table resource model, and a matching resource collection model.

Create a data upgrade script that uses the comments model classes to populate the database.

Create a frontend form block that allows visitors to add comments to category and product pages.

Use the _beforeSave() method to automatically set the associated page and an updated_at timestamp on the comment records.

NACH UNTEN
Jemand vorstellen? Probleme? Fragen? Straight: 15 Minuten CUT!

Sonstiges

NACH UNTEN
Das wird geil, ich freu mich, verzeiht mir Fehler :)

Quellen && nützliche Links

Magento

  • Study Guide Quellensammlung
NACH RECHTS

Danke!

ENDE
Andreas Mautz || andreas.mautz@webvisum.de || webvisum.de