resourcemodel 'failed opening' error
-
12-12-2019 - |
Question
I attempt to call a resourceModel, however, I only recieve a white screen and the following error message within my log:
Warning: include(Namespace/ProjectName/Model/Mysql4/Projectname.php): failed to open stream: No such file or directory
This is how i'm calling the above:
Mage::getResourceModel('projectname/projectname')->uploadData();
This is how the resourceModel is defined in the config.xml:
<models>
<projectname>
<class>Namespace_ProjectName_Model</class>
<resourceModel>projectname_mysql4</resourceModel>
</projectname>
....
</model>
And finally, this is the resourceModel itself:
class Cjponyparts_ProjectName_Model_Mysql4_ProjectName extends Mage_Core_Model_Mysql4_Abstract{
....
function uploadData(){....}
}
The resourceModel is located at:
Namespace/ProjectName/Model/Mysql4/ProjectName.php
The only difference I see that could cause this error is that I have the resourceModel defined as like this "ProjectName.php" while it looks for something like this "Projectname.php". Is this the problem? How can I fix? Do resourceModels need to be defined as the second option?
Solution
if you take a look at the error message
Warning: include(Namespace/ProjectName/Model/Mysql4/Projectname.php): failed to open stream
Failed to open Projectname.php
Try change the class and file name to not be camel-case
Namespace/ProjectName/Model/Mysql4/Projectname.php
class Cjponyparts_ProjectName_Model_Mysql4_Projectname extends Mage_Core_Model_Mysql4_Abstract{
....
function uploadData(){....}
}
Mage::getResourceModel('kitinventory/projectname')
If you want to keep the name camel case try
Mage::getResourceModel('kitinventory/projectName')