Skip to main content
2 of 6
Edited question after the result has changed
GigiSan
  • 143
  • 8

Can't get class of model - Maybe cache problem?

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:

Module tree

./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 no echo

Result with uncommented echo(s):

enter image description here

GigiSan
  • 143
  • 8