0

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.

2

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.