0

I have these files:

app/code/community/Foggyline/HappyHour/Block/Hello.php

class Foggyline_HappyHour_Block_Hello extends Mage_Core_Block_Template
{
   public function __construct()
   {
    parent::__construct();
    $this->setTemplate('foggyline_happyhour/hello.phtml');
   }
}

app/code/community/Foggyline/HappyHour/controllers/HelloController.php
class Foggyline_HappyHour_HelloController extends Mage_Core_Controller_Front_Action
{
public function helloWorldAction()
{
    //echo 'Hello World #1.';
    $this->loadLayout();
    $block = $this->getLayout()->createBlock('foggyline_happyhour/hello');
    //$block->setText('Hello World #2.');
    $this->getLayout()->getBlock('content')->insert($block);
    $this->renderLayout();      
}
}

app/code/community/Foggyline/HappyHour/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
  <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>
                <module>Foggyline_HappyHour</module>
            </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>
<!-- ... other elements ... -->
</config>

app/code/community/Foggyline/HappyHour/Model/User.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');
  }
}

app/code/community/Foggyline/HappyHour/Model/Resource/User.php

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

app/code/community/Foggyline/HappyHour/Model/Resource/User/Collection.php

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

app/code/community/Foggyline/HappyHour/sql/foggyline_happyhour_setup/install-1.0.0.0.php

/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;

$installer->startSetup();

$table = $installer->getConnection()->newTable($installer- 
>getTable('foggyline_happyhour/user'))->addColumn('user_id', 
Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true,), 'Id')->addColumn('firstname', 
Varien_Db_Ddl_Table::TYPE_VARCHAR, null,
array(
  'nullable' => false,
 ), 'User first name')->addColumn('lastname', 
 Varien_Db_Ddl_Table::TYPE_VARCHAR, null,
 array(
 'nullable' => false,
  ), 'User last name')->setComment('Foggyline_HappyHour User Entity');
 $installer->getConnection()->createTable($table);
 $installer->endSetup();

app/etc/modules/Foggyline_HappyHour.xml

<?xml version="1.0"?>
<config>
   <modules>
     <Foggyline_HappyHour>
        <active>true</active>
        <codePool>community</codePool>
     </Foggyline_HappyHour>
   </modules>
 </config>

The problem is when I load a page the install-1.0.0.0.php script run and it creates a row into the core_resource table with these values:

| foggyline_happyhour_setup  | 0.1.1      | 0.1.1        |

The table foggyline_happyhour_user is not been created. I can't figure out what is the problem.

1
  • This mean that your module is well passed but it doesn't create your table, because there is some error in your install script !
    – PЯINCƎ
    Oct 5, 2018 at 16:29

1 Answer 1

0

Here problem with your setup file name and module version. In config.xml you declare 1.0.0.0 but in core_resource table it is 0.1.1.

So delete row foggyline_happyhour_setup | 0.1.1 | 0.1.1 from core_resource table.

Clear cache and run again.

1
  • 1
    Wait ... :) He has written that the install script creates these entries.
    – sv3n
    Oct 5, 2018 at 16:20

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.