sGetCategoryIdByArticleId example


    private function sCategoryPathByProductId($productId$parentId = null)
    {
        $categoryId = $this->moduleManager->Categories()->sGetCategoryIdByArticleId(
            $productId,
            $parentId
        );

        return empty($categoryId) ? null : $this->sCategoryPath($categoryId);
    }

    /** * Generates and inserts the form seo urls * * @param int $offset * @param int $limit * * @throws Exception */

            if ($providedNumber && $providedNumber == $productNumber && empty($selection) || $type === 0) {
                $selection = $product->getSelectedOptions();
            }
        }

        $categoryId = (int) $sCategoryID;
        if (empty($categoryId) || $categoryId == Shopware()->Shop()->getId()) {
            $categoryId = Shopware()->Modules()->Categories()->sGetCategoryIdByArticleId($id);
        }

        return $this->getLegacyProduct(
            $product,
            $categoryId,
            $selection
        );
    }

    /** * calculates the reference price with the base price data * * @param string|float $price | the final price which will be shown * @param string|float $purchaseUnit * @param string|float $referenceUnit * * @return float */

    public function sGetArticleCategoryPath($articleID$separator = ' > ', $categoryID = null, $field = 'name')
    {
        if (empty($categoryID)) {
            $categoryID = $this->sSettings['categoryID'];
        }

        $productCategoryId = $this->sSYSTEM->sMODULES['sCategories']->sGetCategoryIdByArticleId($articleID$categoryID);
        $breadcrumb = array_reverse(Shopware()->Modules()->Categories()->sGetCategoriesByParent($productCategoryId));
        $breadcrumbs = [];

        foreach ($breadcrumb as $breadcrumbObj) {
            $breadcrumbs[] = $field === 'link' ? Shopware()->Modules()->Core()->sRewriteLink($breadcrumbObj[$field]) : $breadcrumbObj[$field];
        }

        return htmlspecialchars_decode(implode($separator$breadcrumbs));
    }

    /** * @param int|string $country * * @return array|false */
Home | Imprint | This part of the site doesn't use cookies.