0

I am trying to learn Magento hard and although I have good understandig of OOP and programming ,still struggling.I am following tutorials ,do the same as there and got errors ,which is very dissapointing.I made module ,this is my config.xml :

<?xml version="1.0"?>
<config>
    <modules>
        <Foggyline_HappyHour>
            <version>1.0.0.0</version>
        </Foggyline_HappyHour>
    </modules>
    <global>
        <models>
 <foggyline_happyhour>
 <class>Foggyline_HappyHour_Model</class>
 <resourceModel>foggyline_happyhour_resource</resourceModel>
 </foggyline_happyhour>
 <foggyline_happyhour_resource>
 <class>Foggyline_HappyHour_Model_Resource</class>
 <entities>
 <user>
 <table>foggyline_happyhour_user</table>
 </user>
 </entities>
 </foggyline_happyhour_resource>
 </models>
 <resources>
 <foggyline_happyhour_setup>
 <setup>
 <model>Foggyline_HappyHour</model>
 </setup>
 </foggyline_happyhour_setup>
 </resources>
    <blocks>
 <foggyline_happyhour>
 <class>Foggyline_HappyHour_Block</class>
 </foggyline_happyhour>
 </blocks>
 </global>
    <frontend>
        <routers>
            <foggyline_happyhour>
                <use>standard</use>
                <args>
                    <module>Foggyline_HappyHour</module>
                    <frontName>happyhour</frontName>
                </args>
            </foggyline_happyhour>
        </routers>
    </frontend>
</config>

In the Model folder I have first User.php :

<?php

class Foggyline_HappyHour_Model_User extends Mage_Core_Model_Abstract
{
   protected $_eventPrefix      = 'foggyline_happyhour_user';
   protected $_eventObject      = 'user';

   protected function _construct()
   {
       $this->_init('foggyline_happyhour/user');
   }
}

in Model/Resuource/User.php :

<?php

class Foggyline_HappyHour_Model_Resource_User extends Mage_Core_Model_Resource_Db_Abstract
{
   protected function _construct()
   {
       $this->_init('foggyline_happyhour/user', 'user_id');
   }
}

and Model/Resuorce/User/Collection.php :

<?php

class Foggyline_HappyHour_Model_Resource_User_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
   public function _construct()
   {
       $this->_init('foggyline_happyhour/user');
   }
}

Also there is some init script for the database ,I don't know whether this is problem with database or something like this?

in my controller I have this function : 
public function testAction(){
        $obj=Mage::getModel('foggyline_happyhour/user');
        var_dump($obj);
     }

page is just crashing with this code ,if I put capital letters 'Foggyline_Happyhour ,page is not crashing and show bool(false) ,which should mean nothing is instantiated,how do I fix this mess is the big question ? I am using Linux btw

2
  • use echo get_class($obj); check what class given u?
    – Amit Bera
    Commented Apr 26, 2016 at 17:37
  • Did you flush caches?
    – goral
    Commented Apr 26, 2016 at 17:40

1 Answer 1

1

in your config.xml, under resources/foggyline_happyhour_setup/setup, you have defined a model tag, but I think it has to be module: https://github.com/bragento/magento-core/blob/1.9/app/code/core/Mage/Cms/etc/config.xml#L167

Also look in you database, if the foggyline_happyhour_user table is created (most likely after you fixed the config.xml and cleared the cache)

2
  • Ok ,I had typo in one class ,now print_r(get_class_methods($obj)) returns all the methods ,the problem is that the database is not created and it throws exception
    – dobrganch
    Commented Apr 26, 2016 at 17:44
  • the database table not beeing created should be an issue with the config.xml, your setup script or maybe some information in the exception. Could you improve your question and post your setup script, the name of the setup script and the exception stack trace pls. also look up the core_resource table if there is already an entry for your module. The setup script is only executed, if there is no entry or you have a new setup script version Commented Apr 26, 2016 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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