Ejemplo n.º 1
0
 /**
  * @param StoreFrontBundle\Struct\Category $category
  * @return array
  * @throws \Exception
  */
 public function convertCategoryStruct(StoreFrontBundle\Struct\Category $category)
 {
     $media = null;
     if ($category->getMedia()) {
         $media = $this->convertMediaStruct($category->getMedia());
     }
     $attribute = [];
     if ($category->hasAttribute('core')) {
         $attribute = $category->getAttribute('core')->toArray();
     }
     return ['id' => $category->getId(), 'parentId' => $category->getParentId(), 'name' => $category->getName(), 'position' => $category->getPosition(), 'metaKeywords' => $category->getMetaKeywords(), 'metaDescription' => $category->getMetaDescription(), 'cmsHeadline' => $category->getCmsHeadline(), 'cmsText' => $category->getCmsText(), 'active' => true, 'template' => $category->getTemplate(), 'productBoxLayout' => $category->getProductBoxLayout(), 'blog' => $category->isBlog(), 'path' => $category->getPath(), 'showFilterGroups' => $category->displayPropertySets(), 'external' => $category->getExternalLink(), 'hideFilter' => !$category->displayFacets(), 'hideTop' => !$category->displayInNavigation(), 'noViewSelect' => $category->allowViewSelect(), 'changed' => null, 'added' => null, 'attribute' => $attribute, 'attributes' => $category->getAttributes(), 'media' => $media, 'link' => $this->getCategoryLink($category)];
 }
Ejemplo n.º 2
0
 /**
  * @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);
 }