title: Magento : Call to a member function count() on a non-object
body: <p>When i add a subcategory in Magento, I get this error:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>This is the function in which line 324 is: </p>
  
  <pre><code>public function drawImgItem($category, $level = 0, $last = false)
  {
     $html = '';
     $categoryName = '';
     if (!$category-&gt;getIsActive()) {
        return $html;
     }
  
     $children = $category-&gt;getChildren();
     $hasChildren = $children &amp;&amp; $children-&gt;count(); &lt;-- This is line 324 which cause error
     $html.= '&lt;li';
     if ($hasChildren) {
         $html.= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
     }
  
     /* snipped by editor for being superfluous */
  }
  </code></pre>