I'm following a video tutorial on Magento for developers and I'm quite a beginner at this. I'm currently using Magento CE 1.9.2.4
.
I created a simple dummy module which controller works fine. Although, when I add a model and try to get its class, the controller action I use to get_class
just gives no result (empty page). If I add an echo before that line I can see the message correctly.
Things I've tried so far:
- checked other similar Q&A but I don't seem to have made the same mistakes
- reset all files chmods to 664 and all folders to 755
- reset all chowns to the standard user:group
- disable and re-enable module output from the Admin > System > Configuration > Advanced section
- re-watched the tutorial steps over and over
I'm out of options now. Seeing the controller working (index and phpinfo actions work fine) it seems like there's a problem in the model itself but I can't find it.
Any help will be greatly appreciated!
EDIT 1
After roughly an hour of checking around for a solution I just refreshed the page and it worked.
This raises even more questions because since I started developing days ago I immediately disabled then purged all caches in the admin and also tried opening the page in browser's private mode many many times with no success.
So it seems like there's something else caching the page, not magento nor my browser. What could it be?
END OF EDIT 1
Some details to follow.
Module tree structure:
./etc/modules/Disc_Prova.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- app/etc/modules/Disc_Prova.xml -->
<config>
<modules>
<Disc_Prova>
<active>true</active>
<codePool>local</codePool>
</Disc_Prova>
</modules>
</config>
./app/code/local/Disc/Prova/etc/config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- app/code/local/Disc/Prova/etc/config.xml -->
<config>
<global>
<blocks>
<Disc_Prova>
<class>Disc_Prova_Block</class>
</Disc_Prova>
</blocks>
<helpers>
<Disc_Prova>
<class>Disc_Prova_Helper</class>
</Disc_Prova>
</helpers>
<models>
<Disc_Prova>
<class>Disc_Prova_Model</class>
</Disc_Prova>
</models>
</global>
<frontend>
<routers>
<disc_prova>
<use>standard</use>
<args>
<module>Disc_Prova</module>
<frontName>prova</frontName>
</args>
</disc_prova>
</routers>
</frontend>
</config>
./app/code/local/Disc/Prova/controllers/IndexController.php:
<?php
class Disc_Prova_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo 'Works!';
}
public function modelAction()
{
// Adding this line shows the text correctly
//echo "blabla1";
echo get_class(Mage::getModel('Disc_Prova/Roba'));
// Adding this line shows the text correctly
//echo "blabla2";
}
public function phpinfoAction()
{
phpinfo();
}
}
./app/code/local/Disc/Prova/Model/Roba.php:
<?php
// app/code/local/Disc/Prova/Model/Roba.php
class Disc_Prova_Model_Roba extends Mage_Core_Model_Abstract
{
}
Result with commented echo(s):
Result with uncommented echo(s):
EDIT 2
I created a new module, Atest_Module
:
./app/etc/modules/Atest_Module.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<atest_module>
<active>true</active>
<codePool>local</codePool>
</atest_module>
</modules>
</config>
./app/code/local/Atest/Module/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- app/code/local/Atest/Module/etc/config.xml -->
<config>
<global>
<blocks>
<atest_module>
<class>Atest_Module_Block</class>
</atest_module>
</blocks>
<helpers>
<atest_module>
<class>Atest_Module_Helper</class>
</atest_module>
</helpers>
<models>
<atest_module>
<class>Atest_Module_Model</class>
</atest_module>
</models>
</global>
<frontend>
<routers>
<atest_module>
<use>standard</use>
<args>
<module>Atest_Module</module>
<frontName>atest</frontName>
</args>
</atest_module>
</routers>
</frontend>
</config>
./app/code/local/Atest/Module/controllers/IndexController.php
class Atest_Module_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo 'Works!';
}
public function modelAction()
{
// Adding this line shows the text correctly
//echo "blabla1";
echo get_class(Mage::getModel('atest_module/roba'));
// Adding this line shows the text correctly
//echo "blabla2";
}
public function phpinfoAction()
{
phpinfo();
}
}
./app/code/local/Atest/Module/Model/Roba.php
<?php
class Atest_Module_Model_Roba extends Mage_Core_Model_Abstract
{
}
Now the controller isn't even hit. I bet if I try in an hour it will work..?
END OF EDIT 2
EDIT 3
After changing the module declaration in /app/etc/modules/Atest_Module.xml to Capitalized, the module works immediately. So at the end, apart from the upper/lower case mishap, I think deleting var/cache made the module appear immediately.
END OF EDIT 3
$obj = Mage::getModel('Disc_Prova/Roba');
echo get_class($obj);
Disc_Prova_Model_Roba
on urlprova/index/model
make sure you clear ur cache or disabled it