src/Entity/Product.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductRepository;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassProductRepository::class)]
  8. class Product
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $slug null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $sku null;
  18.     #[ORM\Column(length255nullabletrue)]
  19.     private ?string $barcode null;
  20.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  21.     private ?string $description null;
  22.     #[ORM\Column]
  23.     private array $images = [];
  24.     #[ORM\Column(nullabletrue)]
  25.     private ?array $videos null;
  26.     #[ORM\Column(nullabletrue)]
  27.     private ?array $documents null;
  28.     #[ORM\Column]
  29.     private ?float $price null;
  30.     #[ORM\Column(nullabletrue)]
  31.     private ?float $compareAtPrice null;
  32.     #[ORM\Column]
  33.     private ?int $stock null;
  34.     #[ORM\Column]
  35.     private ?int $minStockAlert null;
  36.     #[ORM\Column]
  37.     private ?bool $manageStock null;
  38.     #[ORM\Column]
  39.     private ?bool $allowBackorders null;
  40.     #[ORM\Column(length20)]
  41.     private ?string $stockStatus null;
  42.     #[ORM\Column(nullabletrue)]
  43.     private ?float $weight null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?float $length null;
  46.     #[ORM\Column(nullabletrue)]
  47.     private ?float $width null;
  48.     #[ORM\Column(nullabletrue)]
  49.     private ?float $height null;
  50.     #[ORM\Column]
  51.     private ?bool $isDigital null;
  52.     #[ORM\Column(length255nullabletrue)]
  53.     private ?string $digitalFile null;
  54.     #[ORM\Column(nullabletrue)]
  55.     private ?array $attributes null;
  56.     #[ORM\Column(length255nullabletrue)]
  57.     private ?string $color null;
  58.     #[ORM\Column(length255nullabletrue)]
  59.     private ?string $size null;
  60.     #[ORM\Column(length255nullabletrue)]
  61.     private ?string $material null;
  62.     #[ORM\Column(length255nullabletrue)]
  63.     private ?string $itemCondition null;
  64.     #[ORM\Column(nullabletrue)]
  65.     private ?array $variations null;
  66.     #[ORM\Column]
  67.     private ?bool $isActive null;
  68.     #[ORM\Column]
  69.     private ?bool $isFeatured null;
  70.     #[ORM\Column]
  71.     private ?\DateTimeImmutable $publishedAt null;
  72.     #[ORM\Column(nullabletrue)]
  73.     private ?\DateTimeImmutable $availableFrom null;
  74.     #[ORM\Column(nullabletrue)]
  75.     private ?\DateTimeImmutable $availableTo null;
  76.     #[ORM\Column(length255nullabletrue)]
  77.     private ?string $metaTitle null;
  78.     #[ORM\Column(length255nullabletrue)]
  79.     private ?string $metaDescription null;
  80.     #[ORM\Column(length255nullabletrue)]
  81.     private ?string $metaKeywords null;
  82.     #[ORM\Column]
  83.     private ?int $viewCount null;
  84.     #[ORM\Column]
  85.     private ?int $salesCount null;
  86.     #[ORM\Column]
  87.     private ?float $averageRating null;
  88.     #[ORM\Column]
  89.     private ?int $reviewCount null;
  90.     #[ORM\Column(nullabletrue)]
  91.     private ?array $tierPrices null// [{min:int, price:float}, ...]
  92.     #[ORM\Column(options: ["default" => false])]
  93.     private ?bool $hasTierPricing false;
  94.     #[ORM\ManyToOne(inversedBy'products')]
  95.     #[ORM\JoinColumn(nullablefalse)]
  96.     private ?Shop $shop null;
  97.     #[ORM\ManyToOne(inversedBy'products')]
  98.     #[ORM\JoinColumn(nullablefalse)]
  99.     private ?Category $category null;
  100.     #[ORM\ManyToOne(inversedBy'products')]
  101.     #[ORM\JoinColumn(nullabletrue)]
  102.     private ?Brand $brand null;
  103.     #[ORM\OneToMany(targetEntityProductRanking::class, mappedBy'product')]
  104.     private Collection $rankings;
  105.     #[ORM\Column(length255)]
  106.     private ?string $name null;
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function getSlug(): ?string
  112.     {
  113.         return $this->slug;
  114.     }
  115.     public function setSlug(string $slug): static
  116.     {
  117.         $this->slug $slug;
  118.         return $this;
  119.     }
  120.     public function getSku(): ?string
  121.     {
  122.         return $this->sku;
  123.     }
  124.     public function setSku(string $sku): static
  125.     {
  126.         $this->sku $sku;
  127.         return $this;
  128.     }
  129.     public function getBarcode(): ?string
  130.     {
  131.         return $this->barcode;
  132.     }
  133.     public function setBarcode(?string $barcode): static
  134.     {
  135.         $this->barcode $barcode;
  136.         return $this;
  137.     }
  138.     public function getDescription(): ?string
  139.     {
  140.         return $this->description;
  141.     }
  142.     public function setDescription(?string $description): static
  143.     {
  144.         $this->description $description;
  145.         return $this;
  146.     }
  147.     public function getImages(): array
  148.     {
  149.         return $this->images;
  150.     }
  151.     public function setImages(array $images): static
  152.     {
  153.         $this->images $images;
  154.         return $this;
  155.     }
  156.     public function getVideos(): ?array
  157.     {
  158.         return $this->videos;
  159.     }
  160.     public function setVideos(?array $videos): static
  161.     {
  162.         $this->videos $videos;
  163.         return $this;
  164.     }
  165.     public function getDocuments(): ?array
  166.     {
  167.         return $this->documents;
  168.     }
  169.     public function setDocuments(?array $documents): static
  170.     {
  171.         $this->documents $documents;
  172.         return $this;
  173.     }
  174.     public function getPrice(): ?float
  175.     {
  176.         return $this->price;
  177.     }
  178.     public function setPrice(float $price): static
  179.     {
  180.         $this->price $price;
  181.         return $this;
  182.     }
  183.     public function getCompareAtPrice(): ?float
  184.     {
  185.         return $this->compareAtPrice;
  186.     }
  187.     public function setCompareAtPrice(?float $compareAtPrice): static
  188.     {
  189.         $this->compareAtPrice $compareAtPrice;
  190.         return $this;
  191.     }
  192.     public function getStock(): ?int
  193.     {
  194.         return $this->stock;
  195.     }
  196.     public function setStock(int $stock): static
  197.     {
  198.         $this->stock $stock;
  199.         return $this;
  200.     }
  201.     public function getMinStockAlert(): ?int
  202.     {
  203.         return $this->minStockAlert;
  204.     }
  205.     public function setMinStockAlert(int $minStockAlert): static
  206.     {
  207.         $this->minStockAlert $minStockAlert;
  208.         return $this;
  209.     }
  210.     public function isManageStock(): ?bool
  211.     {
  212.         return $this->manageStock;
  213.     }
  214.     public function setManageStock(bool $manageStock): static
  215.     {
  216.         $this->manageStock $manageStock;
  217.         return $this;
  218.     }
  219.     public function isAllowBackorders(): ?bool
  220.     {
  221.         return $this->allowBackorders;
  222.     }
  223.     public function setAllowBackorders(bool $allowBackorders): static
  224.     {
  225.         $this->allowBackorders $allowBackorders;
  226.         return $this;
  227.     }
  228.     public function getStockStatus(): ?string
  229.     {
  230.         return $this->stockStatus;
  231.     }
  232.     public function setStockStatus(string $stockStatus): static
  233.     {
  234.         $this->stockStatus $stockStatus;
  235.         return $this;
  236.     }
  237.     public function getWeight(): ?float
  238.     {
  239.         return $this->weight;
  240.     }
  241.     public function setWeight(?float $weight): static
  242.     {
  243.         $this->weight $weight;
  244.         return $this;
  245.     }
  246.     public function getLength(): ?float
  247.     {
  248.         return $this->length;
  249.     }
  250.     public function setLength(?float $length): static
  251.     {
  252.         $this->length $length;
  253.         return $this;
  254.     }
  255.     public function getWidth(): ?float
  256.     {
  257.         return $this->width;
  258.     }
  259.     public function setWidth(?float $width): static
  260.     {
  261.         $this->width $width;
  262.         return $this;
  263.     }
  264.     public function getHeight(): ?float
  265.     {
  266.         return $this->height;
  267.     }
  268.     public function setHeight(?float $height): static
  269.     {
  270.         $this->height $height;
  271.         return $this;
  272.     }
  273.     public function isIsDigital(): ?bool
  274.     {
  275.         return $this->isDigital;
  276.     }
  277.     public function setIsDigital(bool $isDigital): static
  278.     {
  279.         $this->isDigital $isDigital;
  280.         return $this;
  281.     }
  282.     public function getDigitalFile(): ?string
  283.     {
  284.         return $this->digitalFile;
  285.     }
  286.     public function setDigitalFile(?string $digitalFile): static
  287.     {
  288.         $this->digitalFile $digitalFile;
  289.         return $this;
  290.     }
  291.     public function getAttributes(): ?array
  292.     {
  293.         return $this->attributes;
  294.     }
  295.     public function setAttributes(?array $attributes): static
  296.     {
  297.         $this->attributes $attributes;
  298.         return $this;
  299.     }
  300.     public function getColor(): ?string
  301.     {
  302.         return $this->color;
  303.     }
  304.     public function setColor(?string $color): static
  305.     {
  306.         $this->color $color;
  307.         return $this;
  308.     }
  309.     public function getSize(): ?string
  310.     {
  311.         return $this->size;
  312.     }
  313.     public function setSize(?string $size): static
  314.     {
  315.         $this->size $size;
  316.         return $this;
  317.     }
  318.     public function getMaterial(): ?string
  319.     {
  320.         return $this->material;
  321.     }
  322.     public function setMaterial(?string $material): static
  323.     {
  324.         $this->material $material;
  325.         return $this;
  326.     }
  327.     public function getItemCondition(): ?string
  328.     {
  329.         return $this->itemCondition;
  330.     }
  331.     public function setItemCondition(?string $itemCondition): static
  332.     {
  333.         $this->itemCondition $itemCondition;
  334.         return $this;
  335.     }
  336.     public function getVariations(): ?array
  337.     {
  338.         return $this->variations;
  339.     }
  340.     public function setVariations(?array $variations): static
  341.     {
  342.         $this->variations $variations;
  343.         return $this;
  344.     }
  345.     public function isIsActive(): ?bool
  346.     {
  347.         return $this->isActive;
  348.     }
  349.     public function setIsActive(bool $isActive): static
  350.     {
  351.         $this->isActive $isActive;
  352.         return $this;
  353.     }
  354.     public function isIsFeatured(): ?bool
  355.     {
  356.         return $this->isFeatured;
  357.     }
  358.     public function setIsFeatured(bool $isFeatured): static
  359.     {
  360.         $this->isFeatured $isFeatured;
  361.         return $this;
  362.     }
  363.     public function getPublishedAt(): ?\DateTimeImmutable
  364.     {
  365.         return $this->publishedAt;
  366.     }
  367.     public function setPublishedAt(\DateTimeImmutable $publishedAt): static
  368.     {
  369.         $this->publishedAt $publishedAt;
  370.         return $this;
  371.     }
  372.     public function getAvailableFrom(): ?\DateTimeImmutable
  373.     {
  374.         return $this->availableFrom;
  375.     }
  376.     public function setAvailableFrom(?\DateTimeImmutable $availableFrom): static
  377.     {
  378.         $this->availableFrom $availableFrom;
  379.         return $this;
  380.     }
  381.     public function getAvailableTo(): ?\DateTimeImmutable
  382.     {
  383.         return $this->availableTo;
  384.     }
  385.     public function setAvailableTo(?\DateTimeImmutable $availableTo): static
  386.     {
  387.         $this->availableTo $availableTo;
  388.         return $this;
  389.     }
  390.     public function getMetaTitle(): ?string
  391.     {
  392.         return $this->metaTitle;
  393.     }
  394.     public function setMetaTitle(?string $metaTitle): static
  395.     {
  396.         $this->metaTitle $metaTitle;
  397.         return $this;
  398.     }
  399.     public function getMetaDescription(): ?string
  400.     {
  401.         return $this->metaDescription;
  402.     }
  403.     public function setMetaDescription(?string $metaDescription): static
  404.     {
  405.         $this->metaDescription $metaDescription;
  406.         return $this;
  407.     }
  408.     public function getMetaKeywords(): ?string
  409.     {
  410.         return $this->metaKeywords;
  411.     }
  412.     public function setMetaKeywords(?string $metaKeywords): static
  413.     {
  414.         $this->metaKeywords $metaKeywords;
  415.         return $this;
  416.     }
  417.     public function getViewCount(): ?int
  418.     {
  419.         return $this->viewCount;
  420.     }
  421.     public function setViewCount(int $viewCount): static
  422.     {
  423.         $this->viewCount $viewCount;
  424.         return $this;
  425.     }
  426.     public function getSalesCount(): ?int
  427.     {
  428.         return $this->salesCount;
  429.     }
  430.     public function setSalesCount(int $salesCount): static
  431.     {
  432.         $this->salesCount $salesCount;
  433.         return $this;
  434.     }
  435.     public function getAverageRating(): ?float
  436.     {
  437.         return $this->averageRating;
  438.     }
  439.     public function setAverageRating(float $averageRating): static
  440.     {
  441.         $this->averageRating $averageRating;
  442.         return $this;
  443.     }
  444.     public function getReviewCount(): ?int
  445.     {
  446.         return $this->reviewCount;
  447.     }
  448.     public function setReviewCount(int $reviewCount): static
  449.     {
  450.         $this->reviewCount $reviewCount;
  451.         return $this;
  452.     }
  453.     public function getTierPrices(): ?array
  454.     {
  455.         return $this->tierPrices;
  456.     }
  457.     public function setTierPrices(?array $tierPrices): static
  458.     {
  459.         $this->tierPrices $tierPrices;
  460.         return $this;
  461.     }
  462.     public function hasTierPricing(): ?bool
  463.     {
  464.         return $this->hasTierPricing;
  465.     }
  466.     public function setHasTierPricing(bool $hasTierPricing): static
  467.     {
  468.         $this->hasTierPricing $hasTierPricing;
  469.         return $this;
  470.     }
  471.     public function getShop(): ?Shop
  472.     {
  473.         return $this->shop;
  474.     }
  475.     public function setShop(?Shop $shop): static
  476.     {
  477.         $this->shop $shop;
  478.         return $this;
  479.     }
  480.     public function getCategory(): ?Category
  481.     {
  482.         return $this->category;
  483.     }
  484.     public function setCategory(?Category $category): static
  485.     {
  486.         $this->category $category;
  487.         return $this;
  488.     }
  489.     public function getBrand(): ?Brand
  490.     {
  491.         return $this->brand;
  492.     }
  493.     public function setBrand(?Brand $brand): static
  494.     {
  495.         $this->brand $brand;
  496.         return $this;
  497.     }
  498.     /**
  499.      * @return Collection<int, ProductRanking>
  500.      */
  501.     public function getRankings(): Collection
  502.     {
  503.         return $this->rankings;
  504.     }
  505.     public function addRanking(ProductRanking $ranking): static
  506.     {
  507.         if (!$this->rankings->contains($ranking)) {
  508.             $this->rankings->add($ranking);
  509.             $ranking->setProduct($this);
  510.         }
  511.         return $this;
  512.     }
  513.     public function removeRanking(ProductRanking $ranking): static
  514.     {
  515.         if ($this->rankings->removeElement($ranking)) {
  516.             if ($ranking->getProduct() === $this) {
  517.                 $ranking->setProduct(null);
  518.             }
  519.         }
  520.         return $this;
  521.     }
  522.     /**
  523.      * Obtenir le rang dans une catégorie spécifique
  524.      */
  525.     public function getRankInCategory(Category $category): ?int
  526.     {
  527.         foreach ($this->rankings as $ranking) {
  528.             if ($ranking->getCategory() === $category) {
  529.                 return $ranking->getRank();
  530.             }
  531.         }
  532.         return null;
  533.     }
  534.     /**
  535.      * Obtenir le meilleur rang du produit
  536.      */
  537.     public function getBestRank(): ?int
  538.     {
  539.         $bestRank null;
  540.         foreach ($this->rankings as $ranking) {
  541.             if ($bestRank === null || $ranking->getRank() < $bestRank) {
  542.                 $bestRank $ranking->getRank();
  543.             }
  544.         }
  545.         return $bestRank;
  546.     }
  547.     public function getName(): ?string
  548.     {
  549.         return $this->name;
  550.     }
  551.     public function setName(string $name): static
  552.     {
  553.         $this->name $name;
  554.         return $this;
  555.     }
  556. }