Design patterns which are used in Magento

A design pattern in architecture and computer science is a formal way of documenting a solution to a design problem in a particular field of expertise.

from wikipedia.

Factory:

$product = Mage::getModel(‘catalog/product’);

Singleton:

$category = Mage::getSingleton(‘catalog/session’);

Registry:

$currentCategory = Mage::registry(‘current_category’);

Prototype:

Mage:getModel(‘catalog/product’)->getTypeInstance();

 

 

Event/Listeners:

Mage::dispatchEvent(‘model_load_before’, $params);

 

Object Pool:

$id = Mage::objects()->save($object);

$object = Mage::objects($id);

Iterator:

Mage::getModel(‘catalog/product’)->getCollection();

 

Decorator

<script type=”text/javascript”]]>decorateTable(‘product_comparison’);</script>

View Helper

Mage::helper(‘core’);

 

updating…

Leave a Comment