/** * @param array $_categoryIds * @param Mage_Catalog_Model_Resource_Category_Collection $categoryCollection * @return array */ protected function _getNames(array $_categoryIds, $categoryCollection = null) { if (!empty($categoryCollection)) { $_names = array(); foreach ($_categoryIds as $_id) { /** @var Mage_Catalog_Model_Category $_item */ $_item = $categoryCollection->getItemById($_id); if ($_item) { $_names[] = $_item->getName(); } } return implode(self::PATH_DELIMITER, $_names); } else { return $this->_getNames($_categoryIds, $this->_preparedCollection($_categoryIds)); } }
/** * Based on provided Collection and optionally sort order, returns sorted array of categories. * * @param Mage_Catalog_Model_Resource_Category_Collection $collection * @param string $sortOrder * @return array */ public function getCategoriesFromCollection($collection, $sortOrder = '') { $categories = array(); if ($sortOrder != '') { $sort = explode(',', $sortOrder); foreach ($sort as $id) { $c = $collection->getItemById($id); if ($c != null) { $categories[$id] = $this->categoryToArray($c); } } } else { foreach ($collection as $c) { $id = $c->getId(); $categories[$id] = $this->categoryToArray($c); } } return $categories; }