0

I create custom header in cart page like this

<checkout_cart_index> 
    <reference name="root"> 
        <block type="page/html_header" name="header" as="header">
            <action method="setTemplate"><template>page/html/cartheader.phtml</template></action> 
        </block>          
    </reference>

    <reference name="footer">
        <block type="cms/block" name="Shopping Cart" before="footer_links">
            <action method="setBlockId"><block_id>shoppingcart</block_id></action>
        </block>        
    </reference>

</checkout_cart_index>

then i see my log files it shows below error what is problem on it's

2016-05-06T05:35:51+00:00 ERR (3): exception 'Mage_Core_Exception' with message 'Invalid block type: Mage_Page_Block_Header' in /var/www/html/domain/app/Mage.php:595 Stack trace: #0 /var/www/html/domain/app/code/core/Mage/Core/Model/Layout.php(495): Mage::throwException('Invalid block t...') #1 /var/www/html/domain/app/code/core/Mage/Core/Model/Layout.php(437): Mage_Core_Model_Layout->_getBlockInstance('page/header', Array) #2 /var/www/html/domain/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('page/header', 'header') #3 /var/www/html/domain/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('page/header', 'header') #4 /var/www/html/domain/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 /var/www/html/domain/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element)) #6 /var/www/html/domain/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks() #7 /var/www/html/domain/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks() #8 /var/www/html/domain/app/code/core/Mage/Checkout/controllers/OnepageController.php(212): Mage_Core_Controller_Varien_Action->loadLayout() #9 /var/www/html/domain/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Checkout_OnepageController->indexAction() #10 /var/www/html/domain/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index') #11 /var/www/html/domain/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #12 /var/www/html/domain/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch() #13 /var/www/html/domain/app/Mage.php(684): Mage_Core_Model_App->run(Array) #14 /var/www/html/domain/index.php(83): Mage::run('', 'store') #15 {main}

3 Answers 3

1

Block type is page/html_header not page/header

Change below code

       <reference name="header"> 
            <block type="page/header" name="header">
                <action method="setTemplate"><template>page/html/cartheader.phtml</template></action> 
            </block>
            <remove name="navigation-link"/>
            <remove name="cms_footer_links"/>            
        </reference>

to:

   <reference name="header">            
        <action method="setTemplate"><template>page/html/cartheader.phtml</template></action>            
        <remove name="navigation-link"/>
        <remove name="cms_footer_links"/>            
    </reference>
4
  • Still same error
    – Magento 2
    Commented May 6, 2016 at 6:06
  • Update answer please check it will surely work Commented May 6, 2016 at 6:18
  • No Luck Same Error
    – Magento 2
    Commented May 6, 2016 at 6:24
  • It is working for me may be there is other issue.Clear cache and check it. Commented May 6, 2016 at 6:32
0

Try this code

<reference name="header">
    <block type="page/header" name="header">
        <action method="setTemplate"><template>page/html/cartheader.phtml</template></action> 
    </block> 
</reference>
0

try this with root reference

<checkout_cart_index> 
              <reference name="root">
  <block type="core/template" name="header" as="header" template="page/html/cartheader.phtml"/>
</reference>

        <reference name="footer">
            <block type="cms/block" name="Shopping Cart" before="footer_links">
                <action method="setBlockId"><block_id>shoppingcart</block_id></action>
            </block>        
        </reference>

    </checkout_cart_index>

other solution is

copy app/code/core/Mage/Page/Block/Html/Header.php

to app/code/local/Mage/Page/Block/Html/Header.php

change template in construct

public function _construct()
    {
      $currentUrl = Mage::getUrl('*/*/*', array('_current' => true));
  if (strpos($currentUrl,'checkout/cart') == true) {
        $this->setTemplate('page/html/cartheader.phtml');
  } else { $this->setTemplate('page/html/header.phtml'); }
    }
15
  • Still same i have a doubt it relatedt to header error or what
    – Magento 2
    Commented May 6, 2016 at 7:53
  • did you check error log and remove the cache folder Commented May 6, 2016 at 7:56
  • Yes Still same only \
    – Magento 2
    Commented May 6, 2016 at 7:56
  • update the code try that.. Commented May 6, 2016 at 7:59
  • No luck same error
    – Magento 2
    Commented May 6, 2016 at 9:34

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.