cancel
Showing results for 
Search instead for 
Did you mean: 

category fatal error

category fatal error

Dear Magento,

 

I've got this unknown error home/ordoh/public_html/app/code/core/Mage/Catalog/Model/Observer.php on line 215

 

/**
* Adds catalog categories to top menu
*
* @param Varien_Event_Observer $observer
*/
public function addCatalogToTopmenuItems(Varien_Event_Observer $observer)
{
$block = $observer->getEvent()->getBlock();
$block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG);
$this->_addCategoriesToMenu(
Mage::helper('catalog/category')->getStoreCategories(), $observer->getMenu(), $block
);
}

 

please help me magento 

 

12 REPLIES

Re: category fatal error

Hi,

Can you tell us what error you're getting?

 

And what code is on line 215 in your file you reference?

Problem solved? Click Accept as Solution!
Magento Certified Developer Plus | www.iwebsolutions.co.uk | Magento Small Business Partner

Re: category fatal error

i'm using cpanel and the editor doesn't show number of line so i copy all on 

Fatal error: Call to a member function addCacheTag() on a non-object in /home/ordoh/public_html/app/code/core/Mage/Catalog/Model/Observer.php on line 215

 

 

the problem is them main web only show header and footer but the middle its only show fatal error 

so please to help me magento

 

<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Catalog Observer
*
* @category Mage
* @package Mage_Catalog
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Catalog_Model_Observer
{
/**
* Process catalog ata related with store data changes
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function storeEdit(Varien_Event_Observer $observer)
{
/** @var $store Mage_Core_Model_Store */
$store = $observer->getEvent()->getStore();
if ($store->dataHasChangedFor('group_id')) {
Mage::app()->reinitStores();
/** @var $categoryFlatHelper Mage_Catalog_Helper_Category_Flat */
$categoryFlatHelper = Mage::helper('catalog/category_flat');
if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
Mage::getResourceModel('catalog/category_flat')->synchronize(null, array($store->getId()));
}
Mage::getResourceSingleton('catalog/product')->refreshEnabledIndex($store);
}
return $this;
}

/**
* Process catalog data related with new store
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function storeAdd(Varien_Event_Observer $observer)
{
/* @var $store Mage_Core_Model_Store */
$store = $observer->getEvent()->getStore();
Mage::app()->reinitStores();
Mage::getConfig()->reinit();
/** @var $categoryFlatHelper Mage_Catalog_Helper_Category_Flat */
$categoryFlatHelper = Mage::helper('catalog/category_flat');
if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
Mage::getResourceModel('catalog/category_flat')->synchronize(null, array($store->getId()));
}
Mage::getResourceModel('catalog/product')->refreshEnabledIndex($store);
return $this;
}

/**
* Process catalog data related with store group root category
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function storeGroupSave(Varien_Event_Observer $observer)
{
/* @var $group Mage_Core_Model_Store_Group */
$group = $observer->getEvent()->getGroup();
if ($group->dataHasChangedFor('root_category_id') || $group->dataHasChangedFor('website_id')) {
Mage::app()->reinitStores();
foreach ($group->getStores() as $store) {
/** @var $categoryFlatHelper Mage_Catalog_Helper_Category_Flat */
$categoryFlatHelper = Mage::helper('catalog/category_flat');
if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
Mage::getResourceModel('catalog/category_flat')->synchronize(null, array($store->getId()));
}
}
}
return $this;
}

/**
* Process delete of store
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function storeDelete(Varien_Event_Observer $observer)
{
/** @var $categoryFlatHelper Mage_Catalog_Helper_Category_Flat */
$categoryFlatHelper = Mage::helper('catalog/category_flat');
if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
$store = $observer->getEvent()->getStore();
Mage::getResourceModel('catalog/category_flat')->deleteStores($store->getId());
}
return $this;
}

/**
* Process catalog data after category move
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function categoryMove(Varien_Event_Observer $observer)
{
$categoryId = $observer->getEvent()->getCategoryId();
$prevParentId = $observer->getEvent()->getPrevParentId();
$parentId = $observer->getEvent()->getParentId();
/** @var $categoryFlatHelper Mage_Catalog_Helper_Category_Flat */
$categoryFlatHelper = Mage::helper('catalog/category_flat');
if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
Mage::getResourceModel('catalog/category_flat')->move($categoryId, $prevParentId, $parentId);
}
return $this;
}

/**
* Process catalog data after products import
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function catalogProductImportAfter(Varien_Event_Observer $observer)
{
Mage::getModel('catalog/url')->refreshRewrites();
Mage::getResourceSingleton('catalog/category')->refreshProductIndex();
return $this;
}

/**
* Catalog Product Compare Items Clean
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function catalogProductCompareClean(Varien_Event_Observer $observer)
{
Mage::getModel('catalog/product_compare_item')->clean();
return $this;
}

/**
* After save event of category
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function categorySaveAfter(Varien_Event_Observer $observer)
{
/** @var $categoryFlatHelper Mage_Catalog_Helper_Category_Flat */
$categoryFlatHelper = Mage::helper('catalog/category_flat');
if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
$category = $observer->getEvent()->getCategory();
Mage::getResourceModel('catalog/category_flat')->synchronize($category);
}
return $this;
}

/**
* Checking whether the using static urls in WYSIWYG allowed event
*
* @param Varien_Event_Observer $observer
* @return Mage_Catalog_Model_Observer
*/
public function catalogCheckIsUsingStaticUrlsAllowed(Varien_Event_Observer $observer)
{
$storeId = $observer->getEvent()->getData('store_id');
$result = $observer->getEvent()->getData('result');
$result->isAllowed = Mage::helper('catalog')->setStoreId($storeId)->isUsingStaticUrlsAllowed();
}

/**
* Cron job method for product prices to reindex
*
* @param Mage_Cron_Model_Schedule $schedule
*/
public function reindexProductPrices(Mage_Cron_Model_Schedule $schedule)
{
$indexProcess = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
if ($indexProcess) {
$indexProcess->reindexAll();
}
}

/**
* Adds catalog categories to top menu
*
* @param Varien_Event_Observer $observer
*/
public function addCatalogToTopmenuItems(Varien_Event_Observer $observer)
{
$block = $observer->getEvent()->getBlock();
$block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG);
$this->_addCategoriesToMenu(
Mage::helper('catalog/category')->getStoreCategories(), $observer->getMenu(), $block
);
}

/**
* Recursively adds categories to top menu
*
* @param Varien_Data_Tree_Node_Collection|array $categories
* @param Varien_Data_Tree_Node $parentCategoryNode
* @param Mage_Page_Block_Html_Topmenu $menuBlock
* @param bool $addTags
*/
protected function _addCategoriesToMenu($categories, $parentCategoryNode, $menuBlock, $addTags = false)
{
$categoryModel = Mage::getModel('catalog/category');
foreach ($categories as $category) {
if (!$category->getIsActive()) {
continue;
}

$nodeId = 'category-node-' . $category->getId();

$categoryModel->setId($category->getId());
if ($addTags) {
$menuBlock->addModelTags($categoryModel);
}

$tree = $parentCategoryNode->getTree();
$categoryData = array(
'name' => $category->getName(),
'id' => $nodeId,
'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
'is_active' => $this->_isActiveMenuCategory($category)
);
$categoryNode = new Varien_Data_Tree_Node($categoryData, 'id', $tree, $parentCategoryNode);
$parentCategoryNode->addChild($categoryNode);

$flatHelper = Mage::helper('catalog/category_flat');
if ($flatHelper->isEnabled() && $flatHelper->isBuilt(true)) {
$subcategories = (array)$category->getChildrenNodes();
} else {
$subcategories = $category->getChildren();
}

$this->_addCategoriesToMenu($subcategories, $categoryNode, $menuBlock, $addTags);
}
}

/**
* Checks whether category belongs to active category's path
*
* @param Varien_Data_Tree_Node $category
* @return bool
*/
protected function _isActiveMenuCategory($category)
{
$catalogLayer = Mage::getSingleton('catalog/layer');
if (!$catalogLayer) {
return false;
}

$currentCategory = $catalogLayer->getCurrentCategory();
if (!$currentCategory) {
return false;
}

$categoryPathIds = explode(',', $currentCategory->getPathInStore());
return in_array($category->getId(), $categoryPathIds);
}

/**
* Checks whether attribute_code by current module is reserved
*
* @param Varien_Event_Observer $observer
* @throws Mage_Core_Exception
*/
public function checkReservedAttributeCodes(Varien_Event_Observer $observer)
{
/** @var $attribute Mage_Catalog_Model_Entity_Attribute */
$attribute = $observer->getEvent()->getAttribute();
if (!is_object($attribute)) {
return;
}
/** @var $product Mage_Catalog_Model_Product */
$product = Mage::getModel('catalog/product');
if ($product->isReservedAttribute($attribute)) {
throw new Mage_Core_Exception(
Mage::helper('catalog')->__('The attribute code \'%s\' is reserved by system. Please try another attribute code', $attribute->getAttributeCode())
);
}
}
}

Re: category fatal error

Are you using a theme on your site? - Can you try it without the theme to see if it works as expected?

Problem solved? Click Accept as Solution!
Magento Certified Developer Plus | www.iwebsolutions.co.uk | Magento Small Business Partner

Re: category fatal error

Yes, master. justnow i install the theme from templatetoaster.com/ and then i received the fatal error. so you mean not using theme. how do i not using theme?

Re: category fatal error

Yes i'm trying to using another theme at CMS/design and also show out this fatal error message. what can i do now magento?

Re: category fatal error

Dear Magento,

 

Can you check my web www.weldbro.com and it's show the problem. please magento to help to solve this problem

Re: category fatal error

hi,

The following link looks like what you are experiencing - its likely to be caused by an extension.

 

https://techbandhu.wordpress.com/2013/10/23/topmenu-not-functioning-after-upgrade-magento-1-8-fatal-...

Problem solved? Click Accept as Solution!
Magento Certified Developer Plus | www.iwebsolutions.co.uk | Magento Small Business Partner

Re: category fatal error

Have you recently upgraded your Magento? The function you was upgraded in 1.9

Problem solved? Click Accept as Solution!
www.iwebsolutions.co.uk | Magento Small Business Partner

Re: category fatal error

Hi @raymondtanz42,

 

Check these links out, they will help:
https://techbandhu.wordpress.com/2013/10/23/topmenu-not-functioning-after-upgrade-magento-1-8-fatal-...
https://techbandhu.wordpress.com/tag/magento-upgrade/

Found something useful, please give "Kudos" or "Accept as Solution" for Token of Appreciation.
Free Magento Extensions : https://magecomp.com/free-magento-extensions.html