Our blog

 

Magento Custom Model via Mage::getSingleton()

If you are trying to load a custom model using the build in Mage::getSingleton() method and are struggling because it keeps looking in the Mage/ directory for your model instead of your custom model, the best solution I found was simply to put the entire class name of the model.

eg doesn't work:

PHP:
  1. //trying to load EC/Custom/Model/Blah.php
  2. Mage::getSingleton('EC_custom/blah');

does work

PHP:
  1. //trying to load EC/Custom/Model/Blah.php
  2. Mage::getSingleton('EC_Custom_Model_Blah');

More Reading:

One Comments

bellesebastien
December 14th, 2009

This was very helpful, thank you!

 

 

Leave a Reply