return the primary category of the article (usually just the first one found.

@return TdbShopCategory
760341
public function &GetPrimaryCategory()
    {
        $oCategory = null;
        // if this is a variant, then we want to take the parent object instead - at least if no data is set for the child
        if (!empty($this->fieldShopCategoryId)) {
            $oCategory = &$this->GetFieldShopCategory();
            if (!is_null($oCategory) && false == $oCategory->AllowDisplayInShop()) {
                $oCategory = null;
            }
        }

        if (is_null($oCategory)) {
            $oCategories = &$this->GetFieldShopCategoryList();
            $oCategories->GoToStart();
            if ($oCategories->Length() > 0) {
                $oCategory = &$oCategories->Current();
            }
        }
        if (is_null($oCategory) && $this->IsVariant()) {
            $oParent = &$this->GetFieldVariantParent();
            $oCategory = &$oParent->GetPrimaryCategory();
        }

        return $oCategory;
    }
1056226
protected function magic_get_category() {
        $this->ensure_category_loaded();
        if (!empty($this->_categories)) {
            return reset($this->_categories);
        } else {
            return null;
        }
    }
531387
protected function GetMetaCanonical()
    {
        $sCanonical = '';
        $shopService = $this->getShopService();
        $oShopItem = $shopService->getActiveProduct();
        /** @var $oShopItem TdbShopArticle */
        if ($oShopItem) {
            $oCat = $oShopItem->GetPrimaryCategory();
            $iCat = '';
            if ($oCat) {
                $iCat = $oCat->id;
            }
            $sCanonical = $oShopItem->GetDetailLink(true, $iCat);
        } else {
            $category = $shopService->getActiveCategory();
            if ($category) {
                $currentPage = $this->getInputFilterUtil()->getFilteredInput(TdbShopArticleList::URL_LIST_CURRENT_PAGE, 0);
                $additionalParam = array();
                if (0 !== $currentPage) {
                    $additionalParam = array(TdbShopArticleList::URL_LIST_CURRENT_PAGE => $currentPage);
                }
                $activePage = $this->getActivePageService()->getActivePage();

                return $activePage->GetRealURLPlain($additionalParam, true);
            }
            $sCanonical = parent::GetMetaCanonical();
        }

        return $sCanonical;
    }
1148343
public function getRootCategory()
    {

        // load the default store
        $defaultStore = $this->getDefaultStore();

        // load the actual store view code
        $storeViewCode = $this->getStoreViewCode($defaultStore[MemberNames::CODE]);

        // query weather or not we've a root category or not
        if (isset($this->rootCategories[$storeViewCode])) {
            return $this->rootCategories[$storeViewCode];
        }

        // throw an exception if the root category is NOT available
        throw new \Exception(
            $this->appendExceptionSuffix(
                sprintf('Root category for %s is not available', $storeViewCode)
            )
        );
    }
1296530
public function getCategoryAttribute()
    {
        if(is_null($category = $this->categories->last())) {
            $category = new \stdClass();
            $category->title = 'No name';
            $category->slug = 'none';
            $category->alt_url = null;
            $category->template = null;
        }

        return $category;
    }
1062735
public function get_parent_category() {
        if ($this->is_category_item() or $this->is_course_item()) {
            return $this->get_item_category();

        } else {
            return grade_category::fetch(array('id'=>$this->categoryid));
        }
    }
177367
public function getFirstArticle()
    {
        $oArtList = oxNew(\OxidEsales\Eshop\Application\Model\ArticleList::class);
        $oArtList->setSqlLimit(0, 1);
        $oArtList->loadRecommArticles($this->getId(), $this->_sArticlesFilter);
        $oArtList->rewind();

        return $oArtList->current();
    }
439170
public function getDispSelList()
    {
        if ($this->_aDispSelList === null) {
            if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_perfLoadSelectLists') && \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_perfLoadSelectListsInAList')) {
                $this->_aDispSelList = $this->getSelectLists();
            }
        }

        return $this->_aDispSelList;
    }
445289
public function &GetBreadcrumb()
    {
        $oBreadCrumb = &$this->GetFromInternalCache('oCategoryBreadcrumb');
        if (is_null($oBreadCrumb)) {
            $oBreadCrumb = &TdbShopCategoryList::GetCategoryPath($this->id, null, $this->GetLanguage());
            $this->SetInternalCache('oCategoryBreadcrumb', $oBreadCrumb);
        } else {
            $oBreadCrumb->GoToStart();
        }

        return $oBreadCrumb;
    }
1204212
public function getHasSubCats()
    {
        if (!isset($this->_blHasSubCats)) {
            $this->_blHasSubCats = $this->oxcategories__oxright->value > $this->oxcategories__oxleft->value + 1;
        }

        return $this->_blHasSubCats;
    }
629300
public static function get_default() {
        if ($visiblechildren = self::top()->get_children()) {
            $defcategory = reset($visiblechildren);
        } else {
            $toplevelcategories = self::get_tree(0);
            $defcategoryid = $toplevelcategories[0];
            $defcategory = self::get($defcategoryid, MUST_EXIST, true);
        }
        return $defcategory;
    }
104437
public function getParentCategory()
    {
        $parentCategory = null;
        $currentCategory = $this->getCurrentCategory();
        if (null !== $currentCategory) {
            $parentCategoryId = $currentCategory->getParentId();
            $parentCategory = $this->_categoryRepository->get(
                $parentCategoryId,
                $this->_storeManager->getStore()->getId()
            );
            if (null !== $parentCategory && 1 >= $parentCategory->getLevel()) {
                $parentCategory = null;
            }
        }
        return $parentCategory;
    }
104277
public function getTopStartActionArticles()
    {
        if ($this->_oActionArticles === null) {
            $this->_oActionArticles = false;
            if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_perfLoadAktion')) {
                $oArtList = oxNew(\OxidEsales\Eshop\Application\Model\ArticleList::class);
                $oArtList->loadActionArticles('OXTOPSTART');
                if ($oArtList->count()) {
                    $this->_oTopArticle = $oArtList->current();
                    $this->_oActionArticles = $oArtList;
                }
            }
        }

        return $this->_oActionArticles;
    }
737794
public static function GetActiveCategoryPath()
    {
        static $aCategoryList;
        if (!isset($aCategoryList)) {
            $aCategoryList = null;
            $oCurrentCategory = self::getShopService()->getActiveCategory();
            if (!is_null($oCurrentCategory)) {
                $aCategoryList = array();
                do {
                    $aCategoryList[$oCurrentCategory->id] = $oCurrentCategory;
                } while ($oCurrentCategory = &$oCurrentCategory->GetParent());
                $aCategoryList = array_reverse($aCategoryList, true);
            }
        }

        return $aCategoryList;
    }
693465
public function &GetArticleObject()
    {
        if (is_null($this->oArticle)) {
            $this->oArticle = TdbShopArticle::GetNewInstance();
            if (!$this->oArticle->Load($this->sqlData['shop_article_id'])) {
                $this->oArticle = null;
            }
        }

        return $this->oArticle;
    }
1335208
public function category()
    {
        $category = $this->getCurrentCategory();

        if ($category) {
            $this->blogPosts = $category->BlogPosts();

            if ($this->isRSS()) {
                return $this->rssFeed($this->blogPosts, $category->getLink());
            }
            return $this->render();
        }

        $this->httpError(404, 'Not Found');

        return null;
    }
988659
private static function getInstanceForCategory(TdbShopCategory $activeCategory, TdbShop $oShop)
    {
        $sPkgShopListfilterId = $activeCategory->GetFieldPkgShopListfilterIdRecursive();
        if (empty($sPkgShopListfilterId)) {
            if (!empty($oShop->fieldPkgShopListfilterCategoryFilterId)) {
                $sPkgShopListfilterId = $oShop->fieldPkgShopListfilterCategoryFilterId;
            }
        }

        if (!empty($sPkgShopListfilterId)) {
            return TdbPkgShopListfilter::GetNewInstance($sPkgShopListfilterId);
        }

        return null;
    }