src/Entity/ECommerce/ProductSubCategory.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ECommerce;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation as JMS;
  7. use App\Entity\ECommerce\Traits\DatesInterface;
  8. use App\Entity\ECommerce\Traits\DatesTrait;
  9. /**
  10. * ProductSubGroup
  11. *
  12. * @ORM\Table(name="product_sub_category", indexes={
  13. * @ORM\Index(name="product_sub_group_ids", columns={"id", "remote_id"}),
  14. * })
  15. * @ORM\Entity(repositoryClass="App\Repository\ECommerce\ProductSubCategoryRepository")
  16. * @ORM\Cache(usage="READ_ONLY", region="public")
  17. */
  18. class ProductSubCategory implements DatesInterface
  19. {
  20. /**
  21. * @var int
  22. *
  23. * @ORM\Column(name="id", type="integer")
  24. * @ORM\Id
  25. * @ORM\GeneratedValue(strategy="AUTO")
  26. */
  27. private int $id;
  28. /**
  29. * @ORM\Column(name="remote_id", type="integer", nullable=true)
  30. */
  31. private ?int $remoteId = null;
  32. /**
  33. * @ORM\Column(name="code", type="string", length=2, nullable=true)
  34. */
  35. private ?string $code;
  36. /**
  37. * @ORM\Column(name="name", type="string", length=100)
  38. *
  39. * @JMS\Groups({"cart_private", "product_sub_category", "view_product"})
  40. */
  41. private string $name = '';
  42. /**
  43. * @ORM\ManyToOne(targetEntity="ProductCategory", inversedBy="subCategories")
  44. * @ORM\JoinColumn(name="product_category", nullable=true, referencedColumnName="id")
  45. */
  46. private ?ProductCategory $category = null;
  47. /**
  48. * @ORM\OneToMany(targetEntity="App\Entity\ECommerce\Product", mappedBy="subCategory")
  49. */
  50. private Collection $products;
  51. /**
  52. * @ORM\OneToMany(targetEntity="ProductGroup", mappedBy="subCategory")
  53. */
  54. private Collection $productGroups;
  55. use DatesTrait {
  56. DatesTrait::__construct as __D_construct;
  57. }
  58. public function __construct()
  59. {
  60. $this->products = new ArrayCollection();
  61. }
  62. public function getId(): int
  63. {
  64. return $this->id;
  65. }
  66. /**
  67. * Set remoteId
  68. *
  69. * @param integer $remoteId
  70. */
  71. public function setRemoteId($remoteId): static
  72. {
  73. $this->remoteId = $remoteId;
  74. return $this;
  75. }
  76. /**
  77. * Get remoteId
  78. *
  79. * @return int
  80. */
  81. public function getRemoteId()
  82. {
  83. return $this->remoteId;
  84. }
  85. /**
  86. * Set code
  87. *
  88. * @param string $code
  89. */
  90. public function setCode($code): static
  91. {
  92. $this->code = $code;
  93. return $this;
  94. }
  95. /**
  96. * Get code
  97. *
  98. * @return string
  99. */
  100. public function getCode()
  101. {
  102. return $this->code;
  103. }
  104. /**
  105. * Set name
  106. *
  107. * @param string $name
  108. */
  109. public function setName($name): static
  110. {
  111. $this->name = $name;
  112. return $this;
  113. }
  114. /**
  115. * Get name
  116. *
  117. * @return string
  118. */
  119. public function getName()
  120. {
  121. return $this->name;
  122. }
  123. /**
  124. * Set category
  125. *
  126. *
  127. */
  128. public function setCategory(?ProductCategory $category = null): static
  129. {
  130. $this->category = $category;
  131. return $this;
  132. }
  133. /**
  134. * Get category
  135. *
  136. * @return ProductCategory
  137. */
  138. public function getCategory()
  139. {
  140. return $this->category;
  141. }
  142. /**
  143. * Add product
  144. *
  145. *
  146. */
  147. public function addProduct(\App\Entity\ECommerce\Product $product): static
  148. {
  149. $this->products[] = $product;
  150. return $this;
  151. }
  152. /**
  153. * Remove product
  154. */
  155. public function removeProduct(\App\Entity\ECommerce\Product $product): void
  156. {
  157. $this->products->removeElement($product);
  158. }
  159. /**
  160. * Get products
  161. *
  162. * @return \Doctrine\Common\Collections\Collection
  163. */
  164. public function getProducts()
  165. {
  166. return $this->products;
  167. }
  168. }