Let's say you have a class name Space_Module_Model_LongModelName
and you want to reference it as:
Mage::getModel('module/longmodelname');
This seems to work in some development environments, but doesn't seem to work in all environments. Probably has to do with a file system case sensitivity setting.
The error that you get in environments where it doesn't work is that the include()
for Space/Module/Model/Longmodelname.php
failed.
You have a config-node in your config.xml called global/models/yourpackage in which you save your Prefix for your class models.
When you call Mage::getModel('packagename/classname') Magento fetches this config node e.g. Company_Yourmodule_Models adds a _ and then the classname with uppercase first letter:
Company_Yourmodule_Models_Classname
if you have cAMElcaSe classnames, it is the same way. So let's say your class' name is ClassName then you have to call Mage::getModel('packagename/className') and magento resolves it to: Company_Yourmodule_Models_ClassName
Take a look at app/code/core/Mage/Core/Model/Config.php
specifically getGroupedClassName();
as you'll notice uc_words
is used in the method when building the $className
, which will capitalize every other word in the class name string.
So your class name of LongModelName
will become Longmodelname
for the include.
You could easily extend this to work the way you want but since its such a main piece of Magento's factory generation personally I would not touch it in fear of breaking other 3rd party modules, and live with the non-camel case namespace.
The reason ImportExport works is because it is the module name and not a class name. I've run into the same issue before and as annoying as it is I tend to just keep class names non-Camel cased.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With