Magento 1.9 – Fix ‘Invalid Block Type’ Error in Staging Environment

custommagento-1.9module

I am far from a Magento ninja and I am truly stuck with this… Help!

Version 1.9.2.2

I followed this tutorial and have built two custom modules that work fine in my local development environment. BUT… after moving my code up to a staging environment with a different database my custom modules are not showing up on the page.

The logs below say 'Invalid block type: Mage_Ecosystem_Block_Ecosystem' but the block class is hally9k_EcoSystem_Block_EcoSystem… ??

I think I've tried everything…

I have flushed and disabled all caching.
I have ensured the blocks are white listed in permissions and enabled.

Here is the file structure for one of them:

app -> code -> local -> hally9k -> EcoSystem -> Block -> EcoSystem.php

<?php
// app/code/local/hally9k/EcoSystem/Block/EcoSystem.php
class hally9k_EcoSystem_Block_EcoSystem extends Mage_Core_Block_Template {


    public function getConfig($att)
    {
        $config = Mage::getStoreConfig('ecosystem');
        if (isset($config['ecosystem_config']) ) {
            $value = $config['ecosystem_config'][$att];
            return $value;
        } else {
            throw new Exception($att.' value not set');
        }
    }
}

app -> code -> local -> hally9k -> EcoSystem -> etc -> config.xml

<?xml version="1.0"?>
<!-- app/code/local/hally9k/EcoSystem/etc/config.xml -->
<config>
    <modules>
        <hally9k_EcoSystem>
            <version>1.0</version>
        </hally9k_EcoSystem>
    </modules>
    <global>
        <blocks>
            <ecosystem>
                <class>hally9k_EcoSystem_Block</class>
            </ecosystem>
        </blocks>
        <models>
            <ecosystem>
                <class>hally9k_EcoSystem_Model</class>
            </ecosystem>
        </models>
    </global>
    <default>
        <ecosystem>
            <ecosystem_config>
            </ecosystem_config>
        </ecosystem>
    </default>
</config>

app -> code -> local -> hally9k -> EcoSystem -> Model -> EcoSystem.php

<?php
// app/code/local/hally9k/TileDisplay/Model/TileDisplay.php
class hally9k_EcoSystem_Model_EcoSystem extends Mage_Core_Model_Abstract {

}

app -> etc -> modules -> hally9k_All.xml

<config>
    <modules>
        <hally9k_EcoSystem>
            <active>true</active>
            <codePool>local</codePool>
        </hally9k_EcoSystem>
    </modules>
</config>

The actual template is at:

app -> design -> base -> default -> template -> ecosystem -> ecosystem.phtml

How can I debug this issue?

exception 'Mage_Core_Exception' with message 'Invalid block type: Mage_Ecosystem_Block_Ecosystem' in /home/xxxx/public_html/staging/app/Mage.php:595
Stack trace:
#0 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Model/Layout.php(495): Mage::throwException('Invalid block t...')
#1 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Model/Layout.php(437): Mage_Core_Model_Layout->_getBlockInstance('ecosystem/ecosy...', Array)
#2 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('ecosystem/ecosy...', 'ecosystem_ecosy...')
#3 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('ecosystem/ecosy...', 'ecosystem_ecosy...')
#4 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#5 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Model/Layout.php(206): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#6 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#7 /home/xxxx/public_html/staging/app/code/core/Mage/Cms/Helper/Page.php(113): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#8 /home/xxxx/public_html/staging/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'sahara_digital1...')
#9 /home/xxxx/public_html/staging/app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'sahara_digital1...')
#10 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Cms_IndexController->indexAction()
#11 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#12 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#13 /home/xxxx/public_html/staging/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#14 /home/xxxx/public_html/staging/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#15 /home/xxxx/public_html/staging/index.php(83): Mage::run('', 'store')
#16 {main}

Best Answer

Small Issue with Your code please change Folder and class name and also file name replace hally9k from all places to Hally9k ( make H in capital ) and I think all your problem Is gone.

After That

your config.xml should Be

<?xml version="1.0"?>
<!-- app/code/local/Hally9k/EcoSystem/etc/config.xml -->
<config>
<modules>
    <Hally9k_EcoSystem>
        <version>1.0</version>
    </Hally9k_EcoSystem>
</modules>
<global>
    <blocks>
        <ecosystem>
            <class>Hally9k_EcoSystem_Block</class>
        </ecosystem>
    </blocks>
    <models>
        <ecosystem>
            <class>Hally9k_EcoSystem_Model</class>
        </ecosystem>
    </models>
</global>
<default>
    <ecosystem>
        <ecosystem_config>
        </ecosystem_config>
    </ecosystem>
</default>

Your Blocks Ecosystem.php Should be

<?php
// app/code/local/Hally9k/EcoSystem/Block/EcoSystem.php
class Hally9k_EcoSystem_Block_EcoSystem extends Mage_Core_Block_Template {


public function getConfig($att)
{
    $config = Mage::getStoreConfig('ecosystem');
    if (isset($config['ecosystem_config']) ) {
        $value = $config['ecosystem_config'][$att];
        return $value;
    } else {
        throw new Exception($att.' value not set');
    }
}
}

Your Model EcoSystem.php Should Be

<?php
// app/code/local/Hally9k/TileDisplay/Model/TileDisplay.php
class Hally9k_EcoSystem_Model_EcoSystem extends Mage_Core_Model_Abstract {

}

Make your module file in etc/modules Folder app -> etc -> modules -> Hally9k_All.xml

<config>
<modules>
    <Hally9k_EcoSystem>
        <active>true</active>
        <codePool>local</codePool>
    </Hally9k_EcoSystem>
</modules>
</config>

You Have TO Change Files and folder Name that I have Suggested Make Changes in all Place and Make H capital each and every place where I suggested

Related Topic