vendor/shopware/core/Content/Category/CategoryEntity.php line 18

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Category;
  3. use Shopware\Core\Content\Category\Aggregate\CategoryTranslation\CategoryTranslationCollection;
  4. use Shopware\Core\Content\Cms\CmsPageEntity;
  5. use Shopware\Core\Content\Media\MediaEntity;
  6. use Shopware\Core\Content\Product\ProductCollection;
  7. use Shopware\Core\Content\ProductStream\ProductStreamEntity;
  8. use Shopware\Core\Content\Seo\MainCategory\MainCategoryCollection;
  9. use Shopware\Core\Content\Seo\SeoUrl\SeoUrlCollection;
  10. use Shopware\Core\Framework\DataAbstractionLayer\Entity;
  11. use Shopware\Core\Framework\DataAbstractionLayer\EntityCustomFieldsTrait;
  12. use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
  13. use Shopware\Core\System\SalesChannel\SalesChannelCollection;
  14. use Shopware\Core\System\Tag\TagCollection;
  15. class CategoryEntity extends Entity
  16. {
  17.     use EntityIdTrait;
  18.     use EntityCustomFieldsTrait;
  19.     /**
  20.      * @var string|null
  21.      */
  22.     public $afterCategoryId;
  23.     /**
  24.      * @var string|null
  25.      */
  26.     protected $parentId;
  27.     /**
  28.      * @var int
  29.      */
  30.     protected $autoIncrement;
  31.     /**
  32.      * @var string|null
  33.      */
  34.     protected $mediaId;
  35.     /**
  36.      * @var string|null
  37.      */
  38.     protected $name;
  39.     /**
  40.      * @var array|null
  41.      */
  42.     protected $breadcrumb;
  43.     /**
  44.      * @var string|null
  45.      */
  46.     protected $path;
  47.     /**
  48.      * @var int
  49.      */
  50.     protected $level;
  51.     /**
  52.      * @var bool
  53.      */
  54.     protected $active;
  55.     /**
  56.      * @var int
  57.      */
  58.     protected $childCount;
  59.     /**
  60.      * @var int
  61.      */
  62.     protected $visibleChildCount 0;
  63.     /**
  64.      * @var bool
  65.      */
  66.     protected $displayNestedProducts;
  67.     /**
  68.      * @var CategoryEntity|null
  69.      */
  70.     protected $parent;
  71.     /**
  72.      * @var CategoryCollection|null
  73.      */
  74.     protected $children;
  75.     /**
  76.      * @var CategoryTranslationCollection|null
  77.      */
  78.     protected $translations;
  79.     /**
  80.      * @var MediaEntity|null
  81.      */
  82.     protected $media;
  83.     /**
  84.      * @var ProductCollection|null
  85.      */
  86.     protected $products;
  87.     /**
  88.      * @var ProductCollection|null
  89.      */
  90.     protected $nestedProducts;
  91.     /**
  92.      * @var TagCollection|null
  93.      */
  94.     protected $tags;
  95.     /**
  96.      * @var string|null
  97.      */
  98.     protected $cmsPageId;
  99.     /**
  100.      * @var CmsPageEntity|null
  101.      */
  102.     protected $cmsPage;
  103.     /**
  104.      * @var string|null
  105.      */
  106.     protected $productStreamId;
  107.     /**
  108.      * @var ProductStreamEntity|null
  109.      */
  110.     protected $productStream;
  111.     /**
  112.      * @var array|null
  113.      */
  114.     protected $slotConfig;
  115.     /**
  116.      * @var SalesChannelCollection|null
  117.      */
  118.     protected $navigationSalesChannels;
  119.     /**
  120.      * @var SalesChannelCollection|null
  121.      */
  122.     protected $footerSalesChannels;
  123.     /**
  124.      * @var SalesChannelCollection|null
  125.      */
  126.     protected $serviceSalesChannels;
  127.     /**
  128.      * @var string|null
  129.      */
  130.     protected $linkType;
  131.     /**
  132.      * @var bool|null
  133.      */
  134.     protected $linkNewTab;
  135.     /**
  136.      * @var string|null
  137.      */
  138.     protected $internalLink;
  139.     /**
  140.      * @var string|null
  141.      */
  142.     protected $externalLink;
  143.     /**
  144.      * @var bool
  145.      */
  146.     protected $visible;
  147.     /**
  148.      * @var string
  149.      */
  150.     protected $type;
  151.     /**
  152.      * @var string
  153.      */
  154.     protected $productAssignmentType;
  155.     /**
  156.      * @var string|null
  157.      */
  158.     protected $description;
  159.     /**
  160.      * @var string|null
  161.      */
  162.     protected $metaTitle;
  163.     /**
  164.      * @var string|null
  165.      */
  166.     protected $metaDescription;
  167.     /**
  168.      * @var string|null
  169.      */
  170.     protected $keywords;
  171.     /**
  172.      * @var MainCategoryCollection|null
  173.      */
  174.     protected $mainCategories;
  175.     /**
  176.      * @var SeoUrlCollection|null
  177.      */
  178.     protected $seoUrls;
  179.     public function getParentId(): ?string
  180.     {
  181.         return $this->parentId;
  182.     }
  183.     public function setParentId(?string $parentId): void
  184.     {
  185.         $this->parentId $parentId;
  186.     }
  187.     public function getMediaId(): ?string
  188.     {
  189.         return $this->mediaId;
  190.     }
  191.     public function setMediaId(?string $mediaId): void
  192.     {
  193.         $this->mediaId $mediaId;
  194.     }
  195.     public function getName(): ?string
  196.     {
  197.         return $this->name;
  198.     }
  199.     public function setName(?string $name): void
  200.     {
  201.         $this->name $name;
  202.     }
  203.     public function getPath(): ?string
  204.     {
  205.         return $this->path;
  206.     }
  207.     public function setPath(?string $path): void
  208.     {
  209.         $this->path $path;
  210.     }
  211.     public function getLevel(): int
  212.     {
  213.         return $this->level;
  214.     }
  215.     public function setLevel(int $level): void
  216.     {
  217.         $this->level $level;
  218.     }
  219.     public function getActive(): bool
  220.     {
  221.         return $this->active;
  222.     }
  223.     public function setActive(bool $active): void
  224.     {
  225.         $this->active $active;
  226.     }
  227.     public function getChildCount(): int
  228.     {
  229.         return $this->childCount;
  230.     }
  231.     public function setChildCount(int $childCount): void
  232.     {
  233.         $this->childCount $childCount;
  234.     }
  235.     public function getVisibleChildCount(): int
  236.     {
  237.         return $this->visibleChildCount;
  238.     }
  239.     public function setVisibleChildCount(int $visibleChildCount): void
  240.     {
  241.         $this->visibleChildCount $visibleChildCount;
  242.     }
  243.     public function getParent(): ?CategoryEntity
  244.     {
  245.         return $this->parent;
  246.     }
  247.     public function setParent(CategoryEntity $parent): void
  248.     {
  249.         $this->parent $parent;
  250.     }
  251.     public function getMedia(): ?MediaEntity
  252.     {
  253.         return $this->media;
  254.     }
  255.     public function setMedia(MediaEntity $media): void
  256.     {
  257.         $this->media $media;
  258.     }
  259.     public function getChildren(): ?CategoryCollection
  260.     {
  261.         return $this->children;
  262.     }
  263.     public function setChildren(CategoryCollection $children): void
  264.     {
  265.         $this->children $children;
  266.     }
  267.     public function getTranslations(): ?CategoryTranslationCollection
  268.     {
  269.         return $this->translations;
  270.     }
  271.     public function setTranslations(CategoryTranslationCollection $translations): void
  272.     {
  273.         $this->translations $translations;
  274.     }
  275.     public function getProducts(): ?ProductCollection
  276.     {
  277.         return $this->products;
  278.     }
  279.     public function setProducts(ProductCollection $products): void
  280.     {
  281.         $this->products $products;
  282.     }
  283.     public function getAutoIncrement(): int
  284.     {
  285.         return $this->autoIncrement;
  286.     }
  287.     public function setAutoIncrement(int $autoIncrement): void
  288.     {
  289.         $this->autoIncrement $autoIncrement;
  290.     }
  291.     public function getNestedProducts(): ?ProductCollection
  292.     {
  293.         return $this->nestedProducts;
  294.     }
  295.     public function setNestedProducts(ProductCollection $nestedProducts): void
  296.     {
  297.         $this->nestedProducts $nestedProducts;
  298.     }
  299.     public function getDisplayNestedProducts(): bool
  300.     {
  301.         return $this->displayNestedProducts;
  302.     }
  303.     public function setDisplayNestedProducts(bool $displayNestedProducts): void
  304.     {
  305.         $this->displayNestedProducts $displayNestedProducts;
  306.     }
  307.     public function getAfterCategoryId(): ?string
  308.     {
  309.         return $this->afterCategoryId;
  310.     }
  311.     public function setAfterCategoryId(string $afterCategoryId): void
  312.     {
  313.         $this->afterCategoryId $afterCategoryId;
  314.     }
  315.     public function getTags(): ?TagCollection
  316.     {
  317.         return $this->tags;
  318.     }
  319.     public function setTags(TagCollection $tags): void
  320.     {
  321.         $this->tags $tags;
  322.     }
  323.     public function getCmsPage(): ?CmsPageEntity
  324.     {
  325.         return $this->cmsPage;
  326.     }
  327.     public function setCmsPage(CmsPageEntity $cmsPage): void
  328.     {
  329.         $this->cmsPage $cmsPage;
  330.     }
  331.     public function getCmsPageId(): ?string
  332.     {
  333.         return $this->cmsPageId;
  334.     }
  335.     public function setCmsPageId(string $cmsPageId): void
  336.     {
  337.         $this->cmsPageId $cmsPageId;
  338.     }
  339.     public function getProductStream(): ?ProductStreamEntity
  340.     {
  341.         return $this->productStream;
  342.     }
  343.     public function setProductStream(ProductStreamEntity $productStream): void
  344.     {
  345.         $this->productStream $productStream;
  346.     }
  347.     public function getProductStreamId(): ?string
  348.     {
  349.         return $this->productStreamId;
  350.     }
  351.     public function setProductStreamId(string $productStreamId): void
  352.     {
  353.         $this->productStreamId $productStreamId;
  354.     }
  355.     public function getSlotConfig(): ?array
  356.     {
  357.         return $this->slotConfig;
  358.     }
  359.     public function setSlotConfig(array $slotConfig): void
  360.     {
  361.         $this->slotConfig $slotConfig;
  362.     }
  363.     public function getNavigationSalesChannels(): ?SalesChannelCollection
  364.     {
  365.         return $this->navigationSalesChannels;
  366.     }
  367.     public function setNavigationSalesChannels(SalesChannelCollection $navigationSalesChannels): void
  368.     {
  369.         $this->navigationSalesChannels $navigationSalesChannels;
  370.     }
  371.     public function getFooterSalesChannels(): ?SalesChannelCollection
  372.     {
  373.         return $this->footerSalesChannels;
  374.     }
  375.     public function setFooterSalesChannels(SalesChannelCollection $footerSalesChannels): void
  376.     {
  377.         $this->footerSalesChannels $footerSalesChannels;
  378.     }
  379.     public function getServiceSalesChannels(): ?SalesChannelCollection
  380.     {
  381.         return $this->serviceSalesChannels;
  382.     }
  383.     public function setServiceSalesChannels(SalesChannelCollection $serviceSalesChannels): void
  384.     {
  385.         $this->serviceSalesChannels $serviceSalesChannels;
  386.     }
  387.     public function getLinkType(): ?string
  388.     {
  389.         return $this->linkType;
  390.     }
  391.     public function setLinkType(?string $linkType): void
  392.     {
  393.         $this->linkType $linkType;
  394.     }
  395.     public function getLinkNewTab(): ?bool
  396.     {
  397.         return $this->linkNewTab;
  398.     }
  399.     public function setLinkNewTab(?bool $linkNewTab): void
  400.     {
  401.         $this->linkNewTab $linkNewTab;
  402.     }
  403.     public function getInternalLink(): ?string
  404.     {
  405.         return $this->internalLink;
  406.     }
  407.     public function setInternalLink(?string $internalLink): void
  408.     {
  409.         $this->internalLink $internalLink;
  410.     }
  411.     public function getExternalLink(): ?string
  412.     {
  413.         return $this->externalLink;
  414.     }
  415.     public function setExternalLink(string $externalLink): void
  416.     {
  417.         $this->externalLink $externalLink;
  418.     }
  419.     public function getVisible(): bool
  420.     {
  421.         return $this->visible;
  422.     }
  423.     public function setVisible(bool $visible): void
  424.     {
  425.         $this->visible $visible;
  426.     }
  427.     public function getType(): string
  428.     {
  429.         return $this->type;
  430.     }
  431.     public function setType(string $type): void
  432.     {
  433.         $this->type $type;
  434.     }
  435.     public function getDescription(): ?string
  436.     {
  437.         return $this->description;
  438.     }
  439.     public function setDescription(string $description): void
  440.     {
  441.         $this->description $description;
  442.     }
  443.     public function getBreadcrumb(): array
  444.     {
  445.         return array_values($this->getPlainBreadcrumb());
  446.     }
  447.     public function getPlainBreadcrumb(): array
  448.     {
  449.         $breadcrumb $this->getTranslation('breadcrumb');
  450.         if ($breadcrumb === null) {
  451.             return [];
  452.         }
  453.         if ($this->path === null) {
  454.             return $breadcrumb;
  455.         }
  456.         $parts = \array_slice(explode('|'$this->path), 1, -1);
  457.         $filtered = [];
  458.         foreach ($parts as $id) {
  459.             if (isset($breadcrumb[$id])) {
  460.                 $filtered[$id] = $breadcrumb[$id];
  461.             }
  462.         }
  463.         $filtered[$this->getId()] = $breadcrumb[$this->getId()];
  464.         return $filtered;
  465.     }
  466.     public function setBreadcrumb(?array $breadcrumb): void
  467.     {
  468.         $this->breadcrumb $breadcrumb;
  469.     }
  470.     public function jsonSerialize(): array
  471.     {
  472.         // Make sure that the sorted breadcrumb gets serialized
  473.         $data parent::jsonSerialize();
  474.         $data['translated']['breadcrumb'] = $data['breadcrumb'] = $this->getBreadcrumb();
  475.         return $data;
  476.     }
  477.     public function getMainCategories(): ?MainCategoryCollection
  478.     {
  479.         return $this->mainCategories;
  480.     }
  481.     public function setMainCategories(MainCategoryCollection $mainCategories): void
  482.     {
  483.         $this->mainCategories $mainCategories;
  484.     }
  485.     public function getMetaTitle(): ?string
  486.     {
  487.         return $this->metaTitle;
  488.     }
  489.     public function setMetaTitle(?string $metaTitle): void
  490.     {
  491.         $this->metaTitle $metaTitle;
  492.     }
  493.     public function getMetaDescription(): ?string
  494.     {
  495.         return $this->metaDescription;
  496.     }
  497.     public function setMetaDescription(?string $metaDescription): void
  498.     {
  499.         $this->metaDescription $metaDescription;
  500.     }
  501.     public function getKeywords(): ?string
  502.     {
  503.         return $this->keywords;
  504.     }
  505.     public function setKeywords(?string $keywords): void
  506.     {
  507.         $this->keywords $keywords;
  508.     }
  509.     public function getSeoUrls(): ?SeoUrlCollection
  510.     {
  511.         return $this->seoUrls;
  512.     }
  513.     public function setSeoUrls(SeoUrlCollection $seoUrls): void
  514.     {
  515.         $this->seoUrls $seoUrls;
  516.     }
  517.     public function getProductAssignmentType(): string
  518.     {
  519.         return $this->productAssignmentType;
  520.     }
  521.     public function setProductAssignmentType(string $productAssignmentType): void
  522.     {
  523.         $this->productAssignmentType $productAssignmentType;
  524.     }
  525. }