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 Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI 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.
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, because Mage
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 type
So depending on you want to write to the same or a different object, you use either getSingleton
or getModel