19

Not sure how to figure out this error, I've been googling for a week and I can't seem to find a solution. Any ideas?

2013-06-10T04:04:28+00:00 ERR (3): 
exception 'Mage_Core_Exception' with message 'Invalid block type: ' in /home/xxxxxxx/public_html/app/Mage.php:594
Stack trace:
#0 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Model/Layout.php(495): Mage::throwException('Invalid block t...')
#1 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Model/Layout.php(437): Mage_Core_Model_Layout->_getBlockInstance('', Array)
#2 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('', 'checkout.cart')
#3 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('', 'checkout.cart')
#4 /home/xxxxxxx/public_html/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/xxxxxxx/public_html/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#6 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#7 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#8 /home/xxxxxxx/public_html/app/code/core/Mage/Checkout/controllers/CartController.php(159): Mage_Core_Controller_Varien_Action->loadLayout()
#9 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_CartController->indexAction()
#10 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#11 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#13 /home/xxxxxxx/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#14 /home/xxxxxxx/public_html/index.php(89): Mage::run('', 'store')
#15 {main}
20

Based on the stack trace you posted, it looks like this is happening when Magento is loading the layout update xml files, and using them to create the blocks which will render the HTML for the page.

These lines appear to be the problem

#1 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Model/Layout.php(437): Mage_Core_Model_Layout->_getBlockInstance('', Array)
#2 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('', 'checkout.cart')
#3 /home/xxxxxxx/public_html/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('', 'checkout.cart')

The addBlock, createBlock, and _getBlockInstance methods all expect the first parameter to be a class alias string for the block. Something like checkout/cart. However, in your system, this string is missing.

->addBlock('', 'checkout.cart')

Because Magento's so extendable, there's myriad reasons this might happen. The most common reason is somehow your catalog.xml file has been changed such that this

<block type="checkout/cart" name="checkout.cart">

Is missing it's type attribute. That might look like this

<block name="checkout.cart">

Or it could be a typo

<block typeX="checkout/cart" name="checkout.cart">

Hope that helps. If the problem ends up being something else be sure to come back and post the correct answer.

  • 5
    most probably is something like <block name="checkout.cart"> instead of <reference name="checkout.cart">. I've seen this in a few themes that are on the internet (free or paid). A simple search in the layout folder of the theme should confirm (or dismiss) this theory. – Marius Jun 10 '13 at 6:42
  • 2
    Right, a reference tag wouldn't cause that call stack — createBlock is being called, which means its a block tag. – Alan Storm Jun 10 '13 at 17:22
3

With help from the comments from my original post, I was able to track down the offending code!

Here's the snippet that was causing the exception:

<checkout_cart_index>
    <reference name="content">
        <block name="checkout.cart">            
            <!-- Add CMS Static Block -->
            <block type="cms/block" name="snippet.cart.bottom" as="snippet_cart_bottom">
                <action method="setBlockId"><block_id>snippet_cart_bottom</block_id></action>
            </block>

            <!-- Add CMS Static Block -->
            <block type="cms/block" name="snippet.cart.coupon.below" as="snippet_cart_coupon_below">
                <action method="setBlockId"><block_id>snippet_cart_coupon_below</block_id></action>
            </block>

            <!-- Add CMS Static Block -->
            <block type="cms/block" name="snippet.cart.empty.bottom" as="snippet_cart_empty_bottom">
                <action method="setBlockId"><block_id>snippet_cart_empty_bottom</block_id></action>
            </block>

            <!-- Add CMS Static Block -->
            <block type="cms/block" name="snippet.cart.list.below" as="snippet_cart_list_below">
                <action method="setBlockId"><block_id>snippet_cart_list_below</block_id></action>
            </block>
        </block>
    </reference>
</checkout_cart_index>

Revised code no longer causing exceptions:

<checkout_cart_index>
    <reference name="checkout.cart">        
            <!-- Add CMS Static Block -->
            <block type="cms/block" name="snippet.cart.bottom" as="snippet_cart_bottom">
                <action method="setBlockId"><block_id>snippet_cart_bottom</block_id></action>
            </block>

            <!-- Add CMS Static Block -->
            <block type="cms/block" name="snippet.cart.coupon.below" as="snippet_cart_coupon_below">
                <action method="setBlockId"><block_id>snippet_cart_coupon_below</block_id></action>
            </block>

            <!-- Add CMS Static Block -->
            <block type="cms/block" name="snippet.cart.empty.bottom" as="snippet_cart_empty_bottom">
                <action method="setBlockId"><block_id>snippet_cart_empty_bottom</block_id></action>
            </block>

            <!-- Add CMS Static Block -->
            <block type="cms/block" name="snippet.cart.list.below" as="snippet_cart_list_below">
                <action method="setBlockId"><block_id>snippet_cart_list_below</block_id></action>
            </block>            
    </reference>
</checkout_cart_index>
0

I managed to resolve my issues by just plain old removing the blocks. I did this by:

Adding the line Mage::log($className . ' - ' $blockName, null, 'logfile.log'); to the '_generateBlock' function in /app/code/core/Mage/Core/Model/Layout.php

Like so:

$block = $this->addBlock($className, $blockName);
if (!$block) {
    Mage::log($className . ' - ' $blockName, null, 'logfile.log');
    return $this;
}

I then removed the blocks by adding the following line to my local.xml file in my theme/layout

<remove name="fb8cd356f514800e782dfca09d40465d"/>
<remove name="1f0592cf88e12e898c194d5d18250c51"/>
<remove name="downloads.product"/>

Hope this helps someone. Couldn't stand all the crap being written in my exceptions.log file.

UPDATE:

I have found that using this code just before 'return $this' in the _generateBlock function in /app/code/core/Mage/Core/Model/Layout.php

if ($_SERVER['HTTP_X_FORWARDED_FOR'] == '00.00.00.00') {
    Mage::log(Zend_Debug::dump($parentBlock, null, false), null, 'export_all_xml.log');
}

obviously change 'HTTP_X_FORWARDED_FOR' to 'REMOTE_ADDR' if you need too.

UPDATE 2

I ended up finding the issue wrong with my site by adding:

if ($_SERVER['HTTP_X_FORWARDED_FOR'] == '00.00.00.00') {
    Mage::setIsDeveloperMode(true);
}

just above 'Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block));' in the '_getBlockInstance' function in file '/app/code/core/Mage/Core/Model/Layout.php'

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.