Magento - Mage :: getModel not working on Linux server

I am struggling with a problem for which I cannot find an explanation. I have two development environments that I use for my projects. I created a simple module for Magento and I tested it in one environment. After overcoming all the complications, the Magento module works as expected. This is on XAMPP.

Then I copied the module to the Linux development environment on the host server, and it failed miserably. I did some debugging, and I found out that calling Mage :: getModel () returns bool (false) instead of an instance of the requested model.

I double-checked all files and directories and they match. The database is not involved (not for my part, at least I do not need tables), and in both environments there is only me, as a user, with administrator permissions.

Any suggestion on where I should start looking is welcome, thanks.

Posted on 2012/07/09
The model contains a class called Diego_ClientCustomModule_Model_ExternalUserData , which is called using $model = Mage::getModel('clientcustommodule/externaluserdata'); . The model file is located in Diego_ClientCustomModule\code\local\Diego\ClientCustomModule\Model\ . Curious:

  • If the model file is named Externaluserdata.php , it works.
  • If the model file has the name Externaluserdata.php (i.e. matches the class name), it does not work.

I know information about case sensitivity, etc., but if the alias is all lowercase, how can it load a file that has the first letter with a capital letter?

Configuration file 0.1.0 Diego_ClientCustomModule_Helper Diego_ClientCustomModule_Model Diego_ClientCustomModule_Block standard Diego_ClientCustomModule ClientCustomModule

+4
source share
2 answers

A jury about the structure you are asking for help may not be the best strategy for getting help.

Your problem is probably related to the cache (delete the var / cache folder for verification) or one of the inappropriate packages. Note that the first letter of each directory and the file name for files loaded by the autoloader (blocks, models, and helpers).

+5
source

I seem to have found the root cause of the problem, although I cannot figure out what logic is implemented to make this happen.

The model file name was UserCustomModule.php , which reflected the name of the UserCustomModule class. It made sense and worked great in XAMPP. After I installed the same module in the Linux box, Magento silently ignored the file and, as mentioned earlier, it was not possible to track the actions of Magento.

Following benmark's suggestion, I looked through all the files again to check the case, and everything seemed to fit. I then did something, in my opinion, completely stupid, and I renamed the Model file to Usercustommodule.php , leaving the class name untouched (in the end, PHP should behave the same on both platforms, unlike the file system). Magically, the module is now working! The file name looks cr * p, but it works.

This solved the problem, but raises more questions:

  • Why is Magento having trouble downloading a file called CamelCase? If it's an autoload, it should just find the file and download it. In the end, it loads the controller, block, and everything else, and they are all in CamelCase.
  • Is it written anywhere if one or more files should have only the first letter with a capital letter? I already have enough surprises, I would like, if possible, to avoid new ones.

Thanks again for the help.

+3
source

All Articles