getCategoryPath example

 else {
            $ids = $this->getCategoryIdsOfDepth($category(int) $depth);
            $categories = $this->get(CategoryServiceInterface::class)->getList($ids$context);
            $categoriesArray = $this->convertCategories($categories);
            $categoryTree = $this->getCategoriesOfParent($category$categoriesArray);
            if ($this->Config()->get('caching')) {
                $cache->save($categoryTree$cacheKey['Shopware_Plugin'](int) $this->Config()->get('cachetime', 86400));
            }
            $menu = $categoryTree;
        }

        $categoryPath = $this->getCategoryPath($activeCategoryId);

        return $this->setActiveFlags($menu$categoryPath);
    }

    private function subscribeEvents(): void
    {
        $this->subscribeEvent(
            'Theme_Compiler_Collect_Plugin_Less',
            'onCollectLessFiles'
        );

        

        $this->output->writeln(
            '<error>The given criteria matches multiple categories. Please try again using the category id</error>'
        );

        $tableData = [];

        foreach ($categories as $category) {
            $tableData[] = [
                $category->getId(),
                $category->getName(),
                $this->getCategoryPath($category),
            ];
        }

        $table = new Table($this->output);
        $table
            ->setHeaders(['Id', 'Name', 'Path'])
            ->setRows($tableData);
        $table->render();
    }

    /** * Creates a human readable category path * * @return string */
/** * Returns the category tree from the root until the category * with the provided id. Also loads siblings for elements in the * category path. * * @param int $id Id of the category to load * * @return array Tree of categories */
    public function sGetCategories($id)
    {
        $pathIds = $this->getCategoryPath($id);

        $grouped = $this->getCategoryIdsWithParent($pathIds);

        $ids = array_merge($pathIdsarray_keys($grouped));

        $context = $this->contextService->getShopContext();

        $categories = $this->categoryService->getList($ids$context);

        unset($grouped[$this->baseId]);

        
Home | Imprint | This part of the site doesn't use cookies.