I have seen both function in Magento Files,
What is deference between both function. and also where I use one of them function.
Which is best to load Product Collection.
magento-1.7
I have seen both function in Magento Files,
What is deference between both function. and also where I use one of them function.
Which is best to load Product Collection.
Best Answer
Thanks Amit for the great links, but because we don't have the answer here yet, we can not close the questions a duplicate, so here is the answer:
Magento wants to introduce with
Mage::getSingleton()
the Singleton design pattern. If I understand it correctly it is not exactly a singleton, becauseMage
takes care of only ONE instance. But fact is, if you are using Mage::getSingleton, you get the same object over and over again throughout all your code.Mage::getModel()
is just a standard factory and returns a newly created object of whatever typeSo depending on you want to write to the same or a different object, you use either
getSingleton
orgetModel