/** * @param RecursiveArrayIterator $iterator */ public function fetchCategoriesWithProducts(RecursiveArrayIterator $iterator) { while ($iterator->valid()) { if ($iterator->hasChildren()) { $this->fetchCategoriesWithProducts($iterator->getChildren()); } else { if ($iterator->key() == 'countProducts' && $iterator->current() != '0') { $this->_categoryWithProducts[$iterator->offsetGet('id')] = array('name' => $iterator->offsetGet('name'), 'full_path' => $iterator->offsetGet('full_path'), 'countProduct' => $iterator->offsetGet('countProducts')); } /*$this->_categoryWithProducts[$iterator->offsetGet('id')] = $iterator->offsetGet('countProducts');*/ } $iterator->next(); } }