Created
September 18, 2013 01:00
-
-
Save ryaan-anthony/6603022 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected function _initCategories() | |
| { | |
| $collection = Mage::getResourceModel('catalog/category_collection')->addNameToResult(); | |
| /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */ | |
| foreach ($collection as $category) { | |
| $structure = preg_split('#/+#', $category->getPath()); | |
| $pathSize = count($structure); | |
| if ($pathSize > 1) { | |
| $path = array(); | |
| for ($i = 1; $i < $pathSize; $i++) { | |
| $path[] = $collection->getItemById($structure[$i])->getName(); | |
| } | |
| $this->_rootCategories[$category->getId()] = array_shift($path); | |
| if ($pathSize > 2) { | |
| $this->_categories[$category->getId()] = implode('/', $path); | |
| } | |
| } | |
| } | |
| return $this; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment