public function getRoot($categoryId)
    {
        $category = CategoryQuery::create()->findPk($categoryId);

        if (0 !== $category->getParent()) {
            $parentCategory = CategoryQuery::create()->findPk($category->getParent());

            if (null !== $parentCategory) {
                $categoryId = $this->getRoot($parentCategory->getId());
            }
        }

        return $categoryId;
    }
public function getRoot($categoryId)
    {
        $category = CategoryQuery::create()->findPk($categoryId);

        if (0 !== $category->getParent()) {
            $parentCategory = CategoryQuery::create()->findPk($category->getParent());

            if (null !== $parentCategory) {
                $categoryId = $this->getRoot($parentCategory->getId());
            }
        }

        return $categoryId;
    }
public function getRoot ( $ categoryId ) { $ category = CategoryQuery :: create ( ) -> findPk ( $ categoryId ) ; if ( 0 !== $ category -> getParent ( ) ) { $ parentCategory = CategoryQuery :: create ( ) -> findPk ( $ category -> getParent ( ) ) ; if ( null !== $ parentCategory ) { $ categoryId = $ this -> getRoot ( $ parentCategory -> getId ( ) ) ; } } return $ categoryId ; }
Get the root category
@param  int   $categoryId
@return mixed
Get the root category