Model/ResourceModel/Category.php
protected function getMaxPosition($path)
    {
        $connection = $this->getConnection();
        $positionField = $connection->quoteIdentifier('position');
        $level = count(explode('/', $path));
        $bind = ['c_level' => $level, 'c_path' => $path . '/%'];
        $select = $connection->select()->from(
            $this->getTable('mst_blog_category_entity'),
            'MAX(' . $positionField . ')'
        )->where(
            $connection->quoteIdentifier('path') . ' LIKE :c_path'
        )->where($connection->quoteIdentifier('level') . ' = :c_level');

        $position = $connection->fetchOne($select, $bind);
        if (!$position) {
            $position = 0;
        }
        return $position;
    }
protected function getMaxPosition($path)
    {
        $connection = $this->getConnection();
        $positionField = $connection->quoteIdentifier('position');
        $level = count(explode('/', $path));
        $bind = ['c_level' => $level, 'c_path' => $path . '/%'];
        $select = $connection->select()->from(
            $this->getTable('mst_blog_category_entity'),
            'MAX(' . $positionField . ')'
        )->where(
            $connection->quoteIdentifier('path') . ' LIKE :c_path'
        )->where($connection->quoteIdentifier('level') . ' = :c_level');

        $position = $connection->fetchOne($select, $bind);
        if (!$position) {
            $position = 0;
        }
        return $position;
    }
protected function getMaxPosition ( $ path ) { $ connection = $ this -> getConnection ( ) ; $ positionField = $ connection -> quoteIdentifier ( 'position' ) ; $ level = count ( explode ( '/' , $ path ) ) ; $ bind = [ 'c_level' => $ level , 'c_path' => $ path . '/%' ] ; $ select = $ connection -> select ( ) -> from ( $ this -> getTable ( 'mst_blog_category_entity' ) , 'MAX(' . $ positionField . ')' ) -> where ( $ connection -> quoteIdentifier ( 'path' ) . ' LIKE :c_path' ) -> where ( $ connection -> quoteIdentifier ( 'level' ) . ' = :c_level' ) ; $ position = $ connection -> fetchOne ( $ select , $ bind ) ; if ( ! $ position ) { $ position = 0 ; } return $ position ; }
Get maximum position of child categories by specific tree path

@param string $path
@return int
Get maximum position of child categories by specific tree path