Magento Layered navigation call to count() on undefined object -


i have encountered problem in layered navigation block, believe might bug.

in block mage_catalog_block_navigation, method _rendercategorymenuitemhtml:

    // children     // if flat data enabled use on frontend     $flathelper = mage::helper('catalog/category_flat');     if ($flathelper->isavailable() && $flathelper->isbuilt(true) && !mage::app()->getstore()->isadmin()) {         $children = (array)$category->getchildrennodes();         $childrencount = count($children);     } else {         $children = $category->getchildren();         $childrencount = $children->count();     } 

i have flat category index enabled , index rebuilt when scheduled (every minute). magento version 1.14.0.1 , error message:

call member function count() on non-object 

based on if clause assuming happens when accesses page while index being rebuilt (isavailable).

problem code in else block doesn't seem theoretically work, because $category->getchildren() returns string. missing here? bug or have wrong configuration somwhere.

this may can avoid turning on cache ( cms/catalog/category/404 pages full pages cached in enterprise edition ) , having scheduled cache flush after reindexing complete. consider increasing interval between reindexes.

if tweaking built-in settings doesn't work can debug:

create log file , make writable

touch mage-root/var/log/counts.log chmod 755 mage-root/var/log/counts.log 

replace child calls with:

// children // if flat data enabled use on frontend $flathelper = mage::helper('catalog/category_flat'); mage::log( 'flat data enabled: '  . $flathelper, null, 'counts.log', false ); if ($flathelper->isavailable() && $flathelper->isbuilt(true) && !mage::app()->getstore()->isadmin()) {     $children = (array)$category->getchildrennodes();     mage::log( 'children in if: '  . $children, null, 'counts.log', false );     $childrencount = count($children); } else {     $children = $category->getchildren();     mage::log( 'children in else: '  . $children, null, 'counts.log', false );     $childrencount = $children->count(); } 

finally can override vanilla class copying to:

app\code\local\mage\catalog\block\navigation.php

then adding if( !empty( $children ) ) above offending statement , using 'patch' long term.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -