protected function resolveCategoryIds($categoryId, $topLevel = false, $storeViewCode = StoreViewCodes::ADMIN)
    {

        // return immediately if this is the absolute root node
        if ((integer) $categoryId === 1) {
            return;
        }

        // load the data of the category with the passed ID
        $category = $this->getCategory($categoryId, $storeViewCode);

        // query whether or not the product has already been related
        if (!in_array($categoryId, $this->productCategoryIds)) {
            if ($topLevel) {
                // relate it, if the category is top level
                $this->productCategoryIds[] = $categoryId;
            } elseif ((integer) $category[MemberNames::IS_ANCHOR] === 1) {
                // also relate it, if the category is not top level, but has the anchor flag set
                $this->productCategoryIds[] = $categoryId;
            } else {
                $this->getSubject()
                     ->getSystemLogger()
                     ->debug(sprintf('Don\'t create URL rewrite for category "%s" because of missing anchor flag', $category[MemberNames::PATH]));
            }
        }

        // load the root category
        $rootCategory = $this->getRootCategory();

        // try to resolve the parent category IDs
        if ($rootCategory[MemberNames::ENTITY_ID] !== ($parentId = $category[MemberNames::PARENT_ID])) {
            $this->resolveCategoryIds($parentId, false);
        }
    }
protected function resolveCategoryIds($categoryId, $topLevel = false, $storeViewCode = StoreViewCodes::ADMIN)
    {

        // return immediately if this is the absolute root node
        if ((integer) $categoryId === 1) {
            return;
        }

        // load the data of the category with the passed ID
        $category = $this->getCategory($categoryId, $storeViewCode);

        // query whether or not the product has already been related
        if (!in_array($categoryId, $this->productCategoryIds)) {
            if ($topLevel) {
                // relate it, if the category is top level
                $this->productCategoryIds[] = $categoryId;
            } elseif ((integer) $category[MemberNames::IS_ANCHOR] === 1) {
                // also relate it, if the category is not top level, but has the anchor flag set
                $this->productCategoryIds[] = $categoryId;
            } else {
                $this->getSubject()
                     ->getSystemLogger()
                     ->debug(sprintf('Don\'t create URL rewrite for category "%s" because of missing anchor flag', $category[MemberNames::PATH]));
            }
        }

        // load the root category
        $rootCategory = $this->getRootCategory();

        // try to resolve the parent category IDs
        if ($rootCategory[MemberNames::ENTITY_ID] !== ($parentId = $category[MemberNames::PARENT_ID])) {
            $this->resolveCategoryIds($parentId, false);
        }
    }
protected function resolveCategoryIds ( $ categoryId , $ topLevel = false , $ storeViewCode = StoreViewCodes :: ADMIN ) { // return immediately if this is the absolute root node if ( ( integer ) $ categoryId === 1 ) { return ; } // load the data of the category with the passed ID $ category = $ this -> getCategory ( $ categoryId , $ storeViewCode ) ; // query whether or not the product has already been related if ( ! in_array ( $ categoryId , $ this -> productCategoryIds ) ) { if ( $ topLevel ) { // relate it, if the category is top level $ this -> productCategoryIds [ ] = $ categoryId ; } elseif ( ( integer ) $ category [ MemberNames :: IS_ANCHOR ] === 1 ) { // also relate it, if the category is not top level, but has the anchor flag set $ this -> productCategoryIds [ ] = $ categoryId ; } else { $ this -> getSubject ( ) -> getSystemLogger ( ) -> debug ( sprintf ( 'Don\'t create URL rewrite for category "%s" because of missing anchor flag' , $ category [ MemberNames :: PATH ] ) ) ; } } // load the root category $ rootCategory = $ this -> getRootCategory ( ) ; // try to resolve the parent category IDs if ( $ rootCategory [ MemberNames :: ENTITY_ID ] !== ( $ parentId = $ category [ MemberNames :: PARENT_ID ] ) ) { $ this -> resolveCategoryIds ( $ parentId , false ) ; } }
Resolve's the parent categories of the category with the passed ID and relate's
it with the product with the passed ID, if the category is top level OR has the
anchor flag set.

@param integer $categoryId    The ID of the category to resolve the parents
@param boolean $topLevel      TRUE if the passed category has top level, else FALSE
@param string  $storeViewCode The store view code to resolve the category IDs for

@return void
Resolve s the parent categories of the category with the passed ID and relate s it with the product with the passed ID if the category is top level OR has the anchor flag set .