/** * @param StoreFrontBundle\Struct\Category $category * @return string */ private function getCategoryLink(StoreFrontBundle\Struct\Category $category) { $viewport = $category->isBlog() ? 'blog' : 'cat'; $params = http_build_query(['sViewport' => $viewport, 'sCategory' => $category->getId()], '', '&'); return $this->config->get('baseFile') . '?' . $params; }
/** * @param Category[] $categories * @param Category $category * @param int[] $active * @return \Shopware\Bundle\SearchBundle\FacetResult\TreeItem */ private function createTreeItem($categories, Category $category, $active) { $children = $this->getCategoriesOfParent($categories, $category->getId()); $values = []; foreach ($children as $child) { $values[] = $this->createTreeItem($categories, $child, $active); } return new TreeItem($category->getId(), $category->getName(), in_array($category->getId(), $active), $values); }
/** * @param Struct\Category $category * @return TermFilter */ private function getCategoryFilter(Struct\Category $category) { return new TermFilter('categoryIds', $category->getId()); }
/** * @param Category $category * @param $childrenCounts * @return array */ private function convertCategory(Category $category, $childrenCounts) { $childrenCount = 0; if (isset($childrenCounts[$category->getId()])) { $childrenCount = $childrenCounts[$category->getId()]; } $url = $category->isBlog() ? $this->blogBaseUrl : $this->baseUrl; $attribute = array(); foreach ($category->getAttributes() as $struct) { $attribute = array_merge($attribute, $struct->toArray()); } $media = array(); if ($category->getMedia()) { $media = array('id' => $category->getMedia()->getId(), 'name' => $category->getMedia()->getName(), 'description' => $category->getMedia()->getDescription(), 'path' => $category->getMedia()->getFile(), 'type' => $category->getMedia()->getType(), 'extension' => $category->getMedia()->getExtension()); } $path = $category->getPath() ? '|' . implode('|', $category->getPath()) . '|' : ''; return array('id' => $category->getId(), 'name' => $category->getName(), 'metaKeywords' => $category->getMetaKeywords(), 'metaDescription' => $category->getMetaDescription(), 'cmsHeadline' => $category->getCmsHeadline(), 'cmsText' => $category->getCmsText(), 'active' => true, 'template' => $category->getTemplate(), 'blog' => $category->isBlog(), 'path' => $path, 'external' => $category->getExternalLink(), 'showFilterGroups' => $category->displayPropertySets(), 'hideFilter' => !$category->displayFacets(), 'hideTop' => !$category->displayInNavigation(), 'hidetop' => !$category->displayInNavigation(), 'noViewSelect' => !$category->allowViewSelect(), 'attribute' => $attribute, 'media' => $media, 'description' => $category->getName(), 'link' => $category->getExternalLink() ?: $url . $category->getId(), 'flag' => false, 'subcategories' => array(), 'childrenCount' => $childrenCount); }