当我在Magento中添加子类别时,我收到此错误:
Fatal error: Call to a member function count() on a non-object in C:\wamp\www\cariocawear_new\app\code\local\Mage\Catalog\Block\Navigation.php on line 324
这是第324行的功能:
public function drawImgItem($category, $level = 0, $last = false)
{
$html = '';
$categoryName = '';
if (!$category->getIsActive()) {
return $html;
}
$children = $category->getChildren();
$hasChildren = $children && $children->count(); <-- This is line 324 which cause error
$html.= '<li';
if ($hasChildren) {
$html.= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
}
/* snipped by editor for being superfluous */
}
答案 0 :(得分:0)
这似乎是代码中的一个错误,因为函数$ category-&gt; getChildren()通常会返回一个字符串而不是一个对象。
我认为你应该能够在第323行更换代码时使其工作,但是我还没有测试过它!。
$children = $category->getCollection()
->addFieldToFilter('entity_id', array('in',
explode(',', $category->getChildren())));