Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Fatal error: Call to a member function getPageLayout() on a non-object……….. 
 
webneo
Jr. Member
 
Total Posts:  3
Joined:  2012-04-28
 

Hi,
small code is making error I dont understand:

Fatal error: Call to a member function getPageLayout() on a non-object in C:\inetpub\wwwroot\magento\app\code\core\Mage\Catalog\Block\Product\View.php on line 58

config.xml

<global>
    <
blocks>
      <
catalog>
    <
rewrite>
      <
product_view>First_Module_Block_Product_View</product_view>
    </
rewrite>
      </
catalog>
    </
blocks>

    <
models>
      <
catalog>
    <
rewrite>
      <
product>first_module_model_product</product>
    </
rewrite>
      </
catalog>
    </
models>
  </global>

</
config>

view.php

<?php
class First_Module_Block_Product_View extends Mage_Catalog_Block_Product_View {
}
?>

test.php (the page I use to try the code)

<?php
include 'app/Mage.php';

Mage::app();

$obj_view Mage::app()->getLayout()->createBlock('catalog/product_view');
echo 
get_class($obj_view);
?>

How I should fix ?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
tonyschirmer
Member
 
Avatar
Total Posts:  35
Joined:  2011-10-13
 

Hey webneo,

The error shows:

C:\inetpub\wwwroot\magento\app\code\core\Mage\Catalog\Block\Product\View.php on line 58

You’ve provided your override to that file (not the file where the error is occuring). By the nature of the error, it sounds like it’s excepting a block in the layout file but can’t find it. (make sure that you’re using the $this->loadLayout() in your controller. and that your layout file uses the “update” method of any routes that you’re overriding.

class Mage_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstract
{
.....
    protected function 
_prepareLayout(){
        
.....
        
$headBlock $this->getLayout()->getBlock('head');
        .....
            if (
$title{
                $headBlock
->setTitle($title);
            
}
        
.....
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
webneo
Jr. Member
 
Total Posts:  3
Joined:  2012-04-28
 

@tonyschirmer
Hi,
I did not post the view.php in C:\\inetpub\\wwwroot\\magento\\app\\code\\core\\Mage\\Catalog\\Block\\Product because it is the original installed file and I did not alter.

I am using the community edition do you think this error because I should use the enterprise edition ?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top