public function getCategories()
    {
        if (null === $this->_categories) {

            $collection = Mage::getModel('catalog/category')->getCollection();

            $pathLike = Mage_Catalog_Model_Category::TREE_ROOT_ID . '/' . Mage::app()->getStore()->getRootCategoryId() . '/%';
            $collection
                ->initCache(Mage::app()->getCacheInstance(), self::class, [Mage_Catalog_Model_Category::CACHE_TAG])
                ->setStoreId(Mage::app()->getStore()->getId())
                ->addAttributeToSelect('*')
                ->addFieldToFilter('path', [
                    'like' => $pathLike,
                ])
                ->addIsActiveFilter()
                ->addAttributeToFilter('include_in_menu', 1)
                ->joinUrlRewrite();

            // Sort
            $collection->getSelect()->reset(Zend_Db_Select::ORDER);
            $collection
                ->addOrder('position', Varien_Data_Collection_Db::SORT_ORDER_ASC);

            foreach ($collection as $id => $category) {
                $this->_categories[$id] = $category;
            }
        }

        return $this->_categories;
    }
public function getCategories()
    {
        if (null === $this->_categories) {

            $collection = Mage::getModel('catalog/category')->getCollection();

            $pathLike = Mage_Catalog_Model_Category::TREE_ROOT_ID . '/' . Mage::app()->getStore()->getRootCategoryId() . '/%';
            $collection
                ->initCache(Mage::app()->getCacheInstance(), self::class, [Mage_Catalog_Model_Category::CACHE_TAG])
                ->setStoreId(Mage::app()->getStore()->getId())
                ->addAttributeToSelect('*')
                ->addFieldToFilter('path', [
                    'like' => $pathLike,
                ])
                ->addIsActiveFilter()
                ->addAttributeToFilter('include_in_menu', 1)
                ->joinUrlRewrite();

            // Sort
            $collection->getSelect()->reset(Zend_Db_Select::ORDER);
            $collection
                ->addOrder('position', Varien_Data_Collection_Db::SORT_ORDER_ASC);

            foreach ($collection as $id => $category) {
                $this->_categories[$id] = $category;
            }
        }

        return $this->_categories;
    }
public function getCategories ( ) { if ( null === $ this -> _categories ) { $ collection = Mage :: getModel ( 'catalog/category' ) -> getCollection ( ) ; $ pathLike = Mage_Catalog_Model_Category :: TREE_ROOT_ID . '/' . Mage :: app ( ) -> getStore ( ) -> getRootCategoryId ( ) . '/%' ; $ collection -> initCache ( Mage :: app ( ) -> getCacheInstance ( ) , self :: class , [ Mage_Catalog_Model_Category :: CACHE_TAG ] ) -> setStoreId ( Mage :: app ( ) -> getStore ( ) -> getId ( ) ) -> addAttributeToSelect ( '*' ) -> addFieldToFilter ( 'path' , [ 'like' => $ pathLike , ] ) -> addIsActiveFilter ( ) -> addAttributeToFilter ( 'include_in_menu' , 1 ) -> joinUrlRewrite ( ) ; // Sort $ collection -> getSelect ( ) -> reset ( Zend_Db_Select :: ORDER ) ; $ collection -> addOrder ( 'position' , Varien_Data_Collection_Db :: SORT_ORDER_ASC ) ; foreach ( $ collection as $ id => $ category ) { $ this -> _categories [ $ id ] = $ category ; } } return $ this -> _categories ; }
Give all categories of the current store
@return array Array of all categories
Give all categories of the current store