3

I am trying to follow

http://codemagento.com/2011/03/creating-custom-magento-reports/

the simple report example.

I get the following error:

Fatal error: Call to a member function getReadConnection() on a non-object in /Volumes/Apache/mage/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php on line 134

I can pastebin any code you wanna see but does anyone have any idea why I'm seeing that?

  • 1
    Code from the model and resource model would be great. – Fabian Blechschmidt May 31 '13 at 5:27
7

You have this? It looks like you have no resource model.

<models>
    <awesome>
        <class>Super_Awesome_Model</class>
        <resourceModel>awesome_mysql4</resourceModel>
    </awesome>
     <awesome_mysql4>
        <class>Super_Awesome_Model_Mysql4</class>
</models>

You have to define the class and the resource model.

class Super_Awesome_Model_Simple extends Mage_Core_Model_Abstract
{
    protected function _construct()
    {
        parent::_construct();
        $this->_init('awesome/simple');
    }
}

and the resource model:

class Super_Awesome_Model_Mysql4_Simple extends Mage_Core_Model_Resource_Db_Abstract
{
    protected function _construct()
    {
        $mainTable = 'simple'; // check the node in the config.xml
        $idFieldName = 'simple_id'; // whatever the column is named.
        $this->_init($mainTable, $idFieldName)
    }
}

And to be up to date change now every Mysql4 to Resource. Mysql4 is outdated. Today the resource models are named Namespace_Module_Model_Resource_MyModel

  • the only code I was missing was that last block – user2045 May 31 '13 at 9:20
  • when I added it, it gives me: "Fatal error: Class VMR_Rtest_Model_Mysql4_Simple contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Mage_Core_Model_Resource_Abstract::_getReadAdapter, Mage_Core_Model_Resource_Abstract::_getWriteAdapter) in /Volumes/Apache/mage/app/code/local/VMR/Rtest/Model/Mysql4/Simple.php on line 11" (Bear in mind, I'm using VMR_Rtest instead of that super_awesome stuff) – user2045 May 31 '13 at 9:21
  • Sorry I was wrong, you have to extend Mage_Core_Model_Resource_Abstract – Fabian Blechschmidt May 31 '13 at 14:55
  • It just flew through my twitter stream creare.co.uk/magento-model-basics-the-complete-series – Fabian Blechschmidt May 31 '13 at 15:21
  • where I can found these files? – er.irfankhan11 Jul 12 '16 at 16:13
3

I was also getting the same error. When i checked by system.log of Magento, i got message

"2013-06-26T07:03:11+00:00 ERR (3): Warning: include(<Namespace>/<ModuleName>/Model/Mysql4/<FileName>.php): failed to open stream: No such file or directory in /var/www/<site-name>/lib/Varien/Autoload.php on line 93"

Then i checked in my directory that this particular file was missing. After creating the file, the issue was gone.

  • This was the issue for me too. Thanks a lot! – Vasilii Burlacu Aug 30 '16 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.