2011-02-02 117 views
0

當添加在Magento一個子類別,我得到這個錯誤:的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

這似乎是該代碼中的錯誤,因爲函數$ category-> getChildren()通常返回一個字符串而不是一個對象。

我認爲你應該能夠使它在下面的行323上的代碼替換,但我還沒有測試過!

$children = $category->getCollection() 
     ->addFieldToFilter('entity_id', array('in', 
     explode(',', $category->getChildren()))); 
+0

現在得到這個錯誤出現了一個錯誤處理您的請求SQLSTATE [42S22]:列未發現:在1054未知列'CATEGORY_ID「where子句」 – Muzammil 2011-02-02 14:10:00

相關問題