Magento 1.9 – Fixing Fatal Error on Top Nav Categories Click

categorymagento-1.9

When I click on any of the categories listed in the top nav I go to a blank page with the message:

Fatal error: Call to a member function setLayer() on boolean in magentopath/app/code/core/Mage/Catalog/Block/Layer/View.php on line 134

It's a multistore, until now both stores were running the theme eTheme - BuyShop ver. 2.1 and were working ok.

But now we had to install the theme mgstheme claue_v1.5.1 on one of the stores.

So now the configuration of each store is:

configuration of one store
configuration of the other store

Now the store with the new theme mgstheme claue_v1.5.1 installed do not list any category. I followed the files to an empty collection of categories.

in app/code/design/frontend/mgstheme/claue/template/megamenu/navigation.phtml
there is $megaMenu = $this->getMegamenuItems() and $megaMenu is empty.

in app/code/local/MGS/Megamenu/Block/Megamenu.php is the getMegamenuItems() method.

public function getMegamenuItems(){
    $store = Mage::app()->getStore();
    $menuCollection = Mage::getModel('megamenu/megamenu')
        ->getCollection()
        ->addStoreFilter($store)
        ->addFieldToFilter('parent_id', 1)
        ->addFieldToFilter('status', 1)
        ->setOrder('position', 'ASC')
    ;
    return $menuCollection;
}

And it returns nothing. The categories are created and worked fine in the nav menu before changing the theme.

And the store with the previous theme seems to work ok, but when click on a category, then a blank page with the error Call to a member function setLayer() on boolean is displayed.

I'm not sure where I should to begin looking for the error…

Best Answer

you should look first where the error message says to look : app/code/core/Mage/Catalog/Block/Layer/View.php on line 134

You will see this line :

$this->getLayout()->createBlock($filterBlockName)->setLayer($this->getLayer())

The error message means that Magento failed to create the block : the result of $this->getLayout()->createBlock($filterBlockName) should be an object and it is a boolean (false I guess).

If I were you, I will do some debug with a Mage::log($filterBlockName) before this line (or with x-debug if you know how to do it) to see what type of block failed and why this type does not exist.