예제 #1
0
 public function convertCategory(Models\Category\Category $category)
 {
     $struct = new Struct\Category();
     $struct->setId($category->getId());
     $struct->setName($category->getName());
     $struct->setPath($category->getPath());
     return $struct;
 }
예제 #2
0
 /**
  * @param Struct\Category $category
  * @param array $data
  */
 private function assignCategoryData(Struct\Category $category, array $data)
 {
     if (isset($data['__category_id'])) {
         $category->setId((int) $data['__category_id']);
     }
     if (isset($data['__category_path'])) {
         $path = ltrim($data['__category_path'], '|');
         $path = rtrim($path, '|');
         $path = explode('|', $path);
         $category->setPath(array_reverse($path));
     }
     if (isset($data['__category_description'])) {
         $category->setName($data['__category_description']);
     }
     $category->setParentId((int) $data['__category_parent_id']);
     $category->setPosition((int) $data['__category_position']);
     $category->setProductBoxLayout($data['__category_product_box_layout']);
     if (isset($data['__category_metakeywords'])) {
         $category->setMetaKeywords($data['__category_metakeywords']);
     }
     if (isset($data['__category_metadescription'])) {
         $category->setMetaDescription($data['__category_metadescription']);
     }
     if (isset($data['__category_cmsheadline'])) {
         $category->setCmsHeadline($data['__category_cmsheadline']);
     }
     if (isset($data['__category_cmstext'])) {
         $category->setCmsText($data['__category_cmstext']);
     }
     if (isset($data['__category_template'])) {
         $category->setTemplate($data['__category_template']);
     }
     if (isset($data['__category_noviewselect'])) {
         $category->setAllowViewSelect((bool) (!$data['__category_noviewselect']));
     }
     if (isset($data['__category_blog'])) {
         $category->setBlog((bool) $data['__category_blog']);
     }
     if (isset($data['__category_showfiltergroups'])) {
         $category->setDisplayPropertySets((bool) $data['__category_showfiltergroups']);
     }
     if (isset($data['__category_external'])) {
         $category->setExternalLink($data['__category_external']);
     }
     if (isset($data['__category_hidefilter'])) {
         $category->setDisplayFacets((bool) (!$data['__category_hidefilter']));
     }
     if (isset($data['__category_hidetop'])) {
         $category->setDisplayInNavigation((bool) (!$data['__category_hidetop']));
     }
     if (isset($data['__category_customer_groups'])) {
         $category->setBlockedCustomerGroupIds(explode(',', $data['__category_customer_groups']));
     }
 }
예제 #3
0
 /**
  * @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;
 }
예제 #4
0
 /**
  * @param Struct\Category $category
  * @return TermFilter
  */
 private function getCategoryFilter(Struct\Category $category)
 {
     return new TermFilter('categoryIds', $category->getId());
 }
예제 #5
0
 /**
  * @param ShopEntity $shop
  * @return Shop
  */
 public static function createFromShopEntity(ShopEntity $shop)
 {
     $struct = new self();
     $struct->setId($shop->getId());
     $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId());
     $struct->setIsDefault($shop->getDefault());
     $struct->setName($shop->getName());
     $struct->setHost($shop->getHost());
     $struct->setPath($shop->getBasePath());
     $struct->setUrl($shop->getBaseUrl());
     $struct->setSecure($shop->getSecure());
     $struct->setSecureHost($shop->getSecureHost());
     $struct->setSecurePath($shop->getSecureBasePath());
     if ($shop->getCategory()) {
         $struct->setCategory(Category::createFromCategoryEntity($shop->getCategory()));
     }
     if ($shop->getFallback()) {
         $struct->setFallbackId($shop->getFallback()->getId());
     }
     return $struct;
 }
예제 #6
0
 /**
  * @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);
 }
예제 #7
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);
 }