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<mixed>|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 bool
  101.      */
  102.     protected $cmsPageIdSwitched false;
  103.     /**
  104.      * @var CmsPageEntity|null
  105.      */
  106.     protected $cmsPage;
  107.     /**
  108.      * @var string|null
  109.      */
  110.     protected $productStreamId;
  111.     /**
  112.      * @var ProductStreamEntity|null
  113.      */
  114.     protected $productStream;
  115.     /**
  116.      * @var array<mixed>|null
  117.      */
  118.     protected $slotConfig;
  119.     /**
  120.      * @var SalesChannelCollection|null
  121.      */
  122.     protected $navigationSalesChannels;
  123.     /**
  124.      * @var SalesChannelCollection|null
  125.      */
  126.     protected $footerSalesChannels;
  127.     /**
  128.      * @var SalesChannelCollection|null
  129.      */
  130.     protected $serviceSalesChannels;
  131.     /**
  132.      * @var string|null
  133.      */
  134.     protected $linkType;
  135.     /**
  136.      * @var bool|null
  137.      */
  138.     protected $linkNewTab;
  139.     /**
  140.      * @var string|null
  141.      */
  142.     protected $internalLink;
  143.     /**
  144.      * @var string|null
  145.      */
  146.     protected $externalLink;
  147.     /**
  148.      * @var bool
  149.      */
  150.     protected $visible;
  151.     /**
  152.      * @var string
  153.      */
  154.     protected $type;
  155.     /**
  156.      * @var string
  157.      */
  158.     protected $productAssignmentType;
  159.     /**
  160.      * @var string|null
  161.      */
  162.     protected $description;
  163.     /**
  164.      * @var string|null
  165.      */
  166.     protected $metaTitle;
  167.     /**
  168.      * @var string|null
  169.      */
  170.     protected $metaDescription;
  171.     /**
  172.      * @var string|null
  173.      */
  174.     protected $keywords;
  175.     /**
  176.      * @var MainCategoryCollection|null
  177.      */
  178.     protected $mainCategories;
  179.     /**
  180.      * @var SeoUrlCollection|null
  181.      */
  182.     protected $seoUrls;
  183.     public function getParentId(): ?string
  184.     {
  185.         return $this->parentId;
  186.     }
  187.     public function setParentId(?string $parentId): void
  188.     {
  189.         $this->parentId $parentId;
  190.     }
  191.     public function getMediaId(): ?string
  192.     {
  193.         return $this->mediaId;
  194.     }
  195.     public function setMediaId(?string $mediaId): void
  196.     {
  197.         $this->mediaId $mediaId;
  198.     }
  199.     public function getName(): ?string
  200.     {
  201.         return $this->name;
  202.     }
  203.     public function setName(?string $name): void
  204.     {
  205.         $this->name $name;
  206.     }
  207.     public function getPath(): ?string
  208.     {
  209.         return $this->path;
  210.     }
  211.     public function setPath(?string $path): void
  212.     {
  213.         $this->path $path;
  214.     }
  215.     public function getLevel(): int
  216.     {
  217.         return $this->level;
  218.     }
  219.     public function setLevel(int $level): void
  220.     {
  221.         $this->level $level;
  222.     }
  223.     public function getActive(): bool
  224.     {
  225.         return $this->active;
  226.     }
  227.     public function setActive(bool $active): void
  228.     {
  229.         $this->active $active;
  230.     }
  231.     public function getChildCount(): int
  232.     {
  233.         return $this->childCount;
  234.     }
  235.     public function setChildCount(int $childCount): void
  236.     {
  237.         $this->childCount $childCount;
  238.     }
  239.     public function getVisibleChildCount(): int
  240.     {
  241.         return $this->visibleChildCount;
  242.     }
  243.     public function setVisibleChildCount(int $visibleChildCount): void
  244.     {
  245.         $this->visibleChildCount $visibleChildCount;
  246.     }
  247.     public function getParent(): ?CategoryEntity
  248.     {
  249.         return $this->parent;
  250.     }
  251.     public function setParent(CategoryEntity $parent): void
  252.     {
  253.         $this->parent $parent;
  254.     }
  255.     public function getMedia(): ?MediaEntity
  256.     {
  257.         return $this->media;
  258.     }
  259.     public function setMedia(MediaEntity $media): void
  260.     {
  261.         $this->media $media;
  262.     }
  263.     public function getChildren(): ?CategoryCollection
  264.     {
  265.         return $this->children;
  266.     }
  267.     public function setChildren(CategoryCollection $children): void
  268.     {
  269.         $this->children $children;
  270.     }
  271.     public function getTranslations(): ?CategoryTranslationCollection
  272.     {
  273.         return $this->translations;
  274.     }
  275.     public function setTranslations(CategoryTranslationCollection $translations): void
  276.     {
  277.         $this->translations $translations;
  278.     }
  279.     public function getProducts(): ?ProductCollection
  280.     {
  281.         return $this->products;
  282.     }
  283.     public function setProducts(ProductCollection $products): void
  284.     {
  285.         $this->products $products;
  286.     }
  287.     public function getAutoIncrement(): int
  288.     {
  289.         return $this->autoIncrement;
  290.     }
  291.     public function setAutoIncrement(int $autoIncrement): void
  292.     {
  293.         $this->autoIncrement $autoIncrement;
  294.     }
  295.     public function getNestedProducts(): ?ProductCollection
  296.     {
  297.         return $this->nestedProducts;
  298.     }
  299.     public function setNestedProducts(ProductCollection $nestedProducts): void
  300.     {
  301.         $this->nestedProducts $nestedProducts;
  302.     }
  303.     public function getDisplayNestedProducts(): bool
  304.     {
  305.         return $this->displayNestedProducts;
  306.     }
  307.     public function setDisplayNestedProducts(bool $displayNestedProducts): void
  308.     {
  309.         $this->displayNestedProducts $displayNestedProducts;
  310.     }
  311.     public function getAfterCategoryId(): ?string
  312.     {
  313.         return $this->afterCategoryId;
  314.     }
  315.     public function setAfterCategoryId(string $afterCategoryId): void
  316.     {
  317.         $this->afterCategoryId $afterCategoryId;
  318.     }
  319.     public function getTags(): ?TagCollection
  320.     {
  321.         return $this->tags;
  322.     }
  323.     public function setTags(TagCollection $tags): void
  324.     {
  325.         $this->tags $tags;
  326.     }
  327.     public function getCmsPage(): ?CmsPageEntity
  328.     {
  329.         return $this->cmsPage;
  330.     }
  331.     public function setCmsPage(CmsPageEntity $cmsPage): void
  332.     {
  333.         $this->cmsPage $cmsPage;
  334.     }
  335.     public function getCmsPageId(): ?string
  336.     {
  337.         return $this->cmsPageId;
  338.     }
  339.     public function setCmsPageId(string $cmsPageId): void
  340.     {
  341.         $this->cmsPageId $cmsPageId;
  342.     }
  343.     public function getCmsPageIdSwitched(): bool
  344.     {
  345.         return $this->cmsPageIdSwitched;
  346.     }
  347.     public function setCmsPageIdSwitched(bool $switched): void
  348.     {
  349.         $this->cmsPageIdSwitched $switched;
  350.     }
  351.     public function getProductStream(): ?ProductStreamEntity
  352.     {
  353.         return $this->productStream;
  354.     }
  355.     public function setProductStream(ProductStreamEntity $productStream): void
  356.     {
  357.         $this->productStream $productStream;
  358.     }
  359.     public function getProductStreamId(): ?string
  360.     {
  361.         return $this->productStreamId;
  362.     }
  363.     public function setProductStreamId(string $productStreamId): void
  364.     {
  365.         $this->productStreamId $productStreamId;
  366.     }
  367.     /**
  368.      * @return array<mixed>|null
  369.      */
  370.     public function getSlotConfig(): ?array
  371.     {
  372.         return $this->slotConfig;
  373.     }
  374.     /**
  375.      * @param array<mixed> $slotConfig
  376.      */
  377.     public function setSlotConfig(array $slotConfig): void
  378.     {
  379.         $this->slotConfig $slotConfig;
  380.     }
  381.     public function getNavigationSalesChannels(): ?SalesChannelCollection
  382.     {
  383.         return $this->navigationSalesChannels;
  384.     }
  385.     public function setNavigationSalesChannels(SalesChannelCollection $navigationSalesChannels): void
  386.     {
  387.         $this->navigationSalesChannels $navigationSalesChannels;
  388.     }
  389.     public function getFooterSalesChannels(): ?SalesChannelCollection
  390.     {
  391.         return $this->footerSalesChannels;
  392.     }
  393.     public function setFooterSalesChannels(SalesChannelCollection $footerSalesChannels): void
  394.     {
  395.         $this->footerSalesChannels $footerSalesChannels;
  396.     }
  397.     public function getServiceSalesChannels(): ?SalesChannelCollection
  398.     {
  399.         return $this->serviceSalesChannels;
  400.     }
  401.     public function setServiceSalesChannels(SalesChannelCollection $serviceSalesChannels): void
  402.     {
  403.         $this->serviceSalesChannels $serviceSalesChannels;
  404.     }
  405.     public function getLinkType(): ?string
  406.     {
  407.         return $this->linkType;
  408.     }
  409.     public function setLinkType(?string $linkType): void
  410.     {
  411.         $this->linkType $linkType;
  412.     }
  413.     public function getLinkNewTab(): ?bool
  414.     {
  415.         return $this->linkNewTab;
  416.     }
  417.     public function setLinkNewTab(?bool $linkNewTab): void
  418.     {
  419.         $this->linkNewTab $linkNewTab;
  420.     }
  421.     public function getInternalLink(): ?string
  422.     {
  423.         return $this->internalLink;
  424.     }
  425.     public function setInternalLink(?string $internalLink): void
  426.     {
  427.         $this->internalLink $internalLink;
  428.     }
  429.     public function getExternalLink(): ?string
  430.     {
  431.         return $this->externalLink;
  432.     }
  433.     public function setExternalLink(string $externalLink): void
  434.     {
  435.         $this->externalLink $externalLink;
  436.     }
  437.     public function getVisible(): bool
  438.     {
  439.         return $this->visible;
  440.     }
  441.     public function setVisible(bool $visible): void
  442.     {
  443.         $this->visible $visible;
  444.     }
  445.     public function getType(): string
  446.     {
  447.         return $this->type;
  448.     }
  449.     public function setType(string $type): void
  450.     {
  451.         $this->type $type;
  452.     }
  453.     public function getDescription(): ?string
  454.     {
  455.         return $this->description;
  456.     }
  457.     public function setDescription(string $description): void
  458.     {
  459.         $this->description $description;
  460.     }
  461.     /**
  462.      * @return array<mixed>
  463.      */
  464.     public function getBreadcrumb(): array
  465.     {
  466.         return array_values($this->getPlainBreadcrumb());
  467.     }
  468.     /**
  469.      * @return array<mixed>
  470.      */
  471.     public function getPlainBreadcrumb(): array
  472.     {
  473.         $breadcrumb $this->getTranslation('breadcrumb');
  474.         if ($breadcrumb === null) {
  475.             return [];
  476.         }
  477.         if ($this->path === null) {
  478.             return $breadcrumb;
  479.         }
  480.         $parts = \array_slice(explode('|'$this->path), 1, -1);
  481.         $filtered = [];
  482.         foreach ($parts as $id) {
  483.             if (isset($breadcrumb[$id])) {
  484.                 $filtered[$id] = $breadcrumb[$id];
  485.             }
  486.         }
  487.         $filtered[$this->getId()] = $breadcrumb[$this->getId()];
  488.         return $filtered;
  489.     }
  490.     /**
  491.      * @param array<mixed>|null $breadcrumb
  492.      */
  493.     public function setBreadcrumb(?array $breadcrumb): void
  494.     {
  495.         $this->breadcrumb $breadcrumb;
  496.     }
  497.     /**
  498.      * @return array<mixed>
  499.      */
  500.     public function jsonSerialize(): array
  501.     {
  502.         // Make sure that the sorted breadcrumb gets serialized
  503.         $data parent::jsonSerialize();
  504.         $data['translated']['breadcrumb'] = $data['breadcrumb'] = $this->getBreadcrumb();
  505.         return $data;
  506.     }
  507.     public function getMainCategories(): ?MainCategoryCollection
  508.     {
  509.         return $this->mainCategories;
  510.     }
  511.     public function setMainCategories(MainCategoryCollection $mainCategories): void
  512.     {
  513.         $this->mainCategories $mainCategories;
  514.     }
  515.     public function getMetaTitle(): ?string
  516.     {
  517.         return $this->metaTitle;
  518.     }
  519.     public function setMetaTitle(?string $metaTitle): void
  520.     {
  521.         $this->metaTitle $metaTitle;
  522.     }
  523.     public function getMetaDescription(): ?string
  524.     {
  525.         return $this->metaDescription;
  526.     }
  527.     public function setMetaDescription(?string $metaDescription): void
  528.     {
  529.         $this->metaDescription $metaDescription;
  530.     }
  531.     public function getKeywords(): ?string
  532.     {
  533.         return $this->keywords;
  534.     }
  535.     public function setKeywords(?string $keywords): void
  536.     {
  537.         $this->keywords $keywords;
  538.     }
  539.     public function getSeoUrls(): ?SeoUrlCollection
  540.     {
  541.         return $this->seoUrls;
  542.     }
  543.     public function setSeoUrls(SeoUrlCollection $seoUrls): void
  544.     {
  545.         $this->seoUrls $seoUrls;
  546.     }
  547.     public function getProductAssignmentType(): string
  548.     {
  549.         return $this->productAssignmentType;
  550.     }
  551.     public function setProductAssignmentType(string $productAssignmentType): void
  552.     {
  553.         $this->productAssignmentType $productAssignmentType;
  554.     }
  555. }