Magento 1.7 Error – How to Diagnose ‘Invalid Block Type’ Error

blockserrormagento-1.7

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}

Best Answer

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.

Related Topic