Tag Archive for design-patterns-in-magento

Magento Registry Design Patterns

In magento  registry pattern is allows any object or data to be available in a public global scope for any resource to use. In magento you can set and get any object and data via registry pattern.

You can register an object or data like  below :

 

After it is registered, you can call like  below :

 

You can also unregister an object at any time like  below :

 

For More About Design Patterns Click here

Magento Singleton Design Patterns

The Singleton pattern in magento is instantiated for Blocks and Classes same as factory class abstraction and class groups in Magento .
Instead of the regular getModel() method, you now call:

If model was already instantiated singleton will return the instance, otherwise it will create a new one. Quite handy because in some cases you don’t want to create another instance to be created (e.g. config, order, quote etc).

 

Like as below:

 

For More About Design Patterns Click here