Difference between getSingleton and getModel in magento.

It’s very important question for interview in magento what is the Difference between getSingleton and getModel in magento.

Mage::getSingleton() will first check if the same class instance exists or not in the memory. If the instance exists then it will return the same object from the memory. and if not than it will create a new instance of the class.

Mage::getSingleton() is faster than Mage::getModel().

example:- $product1 = Mage::getSingleton(‘catalog/product’);

Mage::getModel() will create a new instance of an object each time even such object exists in configuration.

getModel will always return a new instance of the requested model every time.

example:- $product1 = Mage::getSingleton(‘catalog/product’);

Leave a Reply