You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProductFamily.php 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\ShopBundle\Context\FilterMerchantInterface;
  7. use Lc\ShopBundle\Context\ProductInterface;
  8. use Lc\ShopBundle\Context\ProductPropertyInterface;
  9. /**
  10. * @ORM\MappedSuperclass()
  11. */
  12. abstract class ProductFamily extends AbstractDocumentEntity implements ProductPropertyInterface, FilterMerchantInterface
  13. {
  14. use ProductPropertyTrait;
  15. /**
  16. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
  17. * @ORM\JoinColumn(nullable=false)
  18. */
  19. protected $merchant;
  20. /**
  21. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", inversedBy="productFamilies")
  22. */
  23. protected $productCategories;
  24. /**
  25. * @ORM\Column(type="boolean")
  26. */
  27. protected $activeProducts;
  28. /**
  29. * @ORM\Column(type="string", length=255, nullable=true)
  30. */
  31. protected $productsType;
  32. /**
  33. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductInterface", mappedBy="productFamily", orphanRemoval=true, cascade={"persist"})
  34. */
  35. protected $products;
  36. /**
  37. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
  38. * @ORM\JoinColumn(nullable=true)
  39. */
  40. protected $taxRate;
  41. /**
  42. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
  43. */
  44. protected $supplierTaxRate;
  45. /**
  46. * @ORM\Column(type="string", length=255, nullable=true)
  47. */
  48. protected $subTitle;
  49. /**
  50. * @ORM\Column(type="text", nullable=true)
  51. */
  52. protected $note;
  53. /**
  54. * @ORM\Column(type="string", length=31, nullable=true)
  55. */
  56. protected $behaviorOutOfStock;
  57. /**
  58. * @ORM\Column(type="string", length=31)
  59. */
  60. protected $behaviorCountStock;
  61. /**
  62. * @ORM\Column(type="boolean", nullable=true)
  63. */
  64. protected $isNovelty;
  65. /**
  66. * @ORM\Column(type="date", nullable=true)
  67. */
  68. protected $noveltyExpirationDate;
  69. /**
  70. * @ORM\Column(type="boolean", nullable=true)
  71. */
  72. protected $isOrganic;
  73. /**
  74. * @ORM\Column(type="string", length=255, nullable=true)
  75. */
  76. protected $organicLabel;
  77. public function __construct()
  78. {
  79. $this->productCategories = new ArrayCollection();
  80. $this->products = new ArrayCollection();
  81. }
  82. public function getMerchant(): ?Merchant
  83. {
  84. return $this->merchant;
  85. }
  86. public function setMerchant(?Merchant $merchant): self
  87. {
  88. $this->merchant = $merchant;
  89. return $this;
  90. }
  91. public function getActiveProducts(): ?bool
  92. {
  93. return $this->activeProducts;
  94. }
  95. public function setActiveProducts(bool $activeProducts): self
  96. {
  97. $this->activeProducts = $activeProducts;
  98. return $this;
  99. }
  100. public function getProductsType(): ?string
  101. {
  102. return $this->productsType;
  103. }
  104. public function setProductsType(?string $productsType): self
  105. {
  106. $this->productsType = $productsType;
  107. return $this;
  108. }
  109. /**
  110. * @return Collection|ProductInterface[]
  111. */
  112. public function getProducts(): Collection
  113. {
  114. return $this->products;
  115. }
  116. public function addProduct(ProductInterface $product): self
  117. {
  118. if (!$this->products->contains($product)) {
  119. $this->products[] = $product;
  120. $product->setProductFamily($this);
  121. }
  122. return $this;
  123. }
  124. public function removeProduct(ProductInterface $product): self
  125. {
  126. if ($this->products->contains($product)) {
  127. $this->products->removeElement($product);
  128. // set the owning side to null (unless already changed)
  129. if ($product->getProductFamily() === $this) {
  130. $product->setProductFamily(null);
  131. }
  132. }
  133. return $this;
  134. }
  135. /**
  136. * @return Collection|ProductCategory[]
  137. */
  138. public function getProductCategories(): Collection
  139. {
  140. return $this->productCategories;
  141. }
  142. public function initProductCategories()
  143. {
  144. $this->productCategories = new ArrayCollection();
  145. }
  146. public function addProductCategory(ProductCategory $productCategory): self
  147. {
  148. if (!$this->productCategories->contains($productCategory)) {
  149. $this->productCategories[] = $productCategory;
  150. }
  151. return $this;
  152. }
  153. public function removeProductCategory(ProductCategory $productCategory): self
  154. {
  155. if ($this->productCategories->contains($productCategory)) {
  156. $this->productCategories->removeElement($productCategory);
  157. }
  158. return $this;
  159. }
  160. public function getTaxRate(): ?TaxRate
  161. {
  162. return $this->taxRate;
  163. }
  164. public function setTaxRate(?TaxRate $taxRate): self
  165. {
  166. $this->taxRate = $taxRate;
  167. return $this;
  168. }
  169. public function getSupplierTaxRate(): ?TaxRate
  170. {
  171. return $this->supplierTaxRate;
  172. }
  173. public function setSupplierTaxRate(?TaxRate $supplierTaxRate): self
  174. {
  175. $this->supplierTaxRate = $supplierTaxRate;
  176. return $this;
  177. }
  178. public function getSubTitle(): ?string
  179. {
  180. return $this->subTitle;
  181. }
  182. public function setSubTitle(?string $subTitle): self
  183. {
  184. $this->subTitle = $subTitle;
  185. return $this;
  186. }
  187. public function getNote(): ?string
  188. {
  189. return $this->note;
  190. }
  191. public function setNote(?string $note): self
  192. {
  193. $this->note = $note;
  194. return $this;
  195. }
  196. public function getBehaviorOutOfStock(): ?string
  197. {
  198. return $this->behaviorOutOfStock;
  199. }
  200. public function setBehaviorOutOfStock(?string $behaviorOutOfStock): self
  201. {
  202. $this->behaviorOutOfStock = $behaviorOutOfStock;
  203. return $this;
  204. }
  205. public function getBehaviorCountStock(): ?string
  206. {
  207. return $this->behaviorCountStock;
  208. }
  209. public function setBehaviorCountStock(string $behaviorCountStock): self
  210. {
  211. $this->behaviorCountStock = $behaviorCountStock;
  212. return $this;
  213. }
  214. public function getIsNovelty(): ?bool
  215. {
  216. return $this->isNovelty;
  217. }
  218. public function setIsNovelty(?bool $isNovelty): self
  219. {
  220. $this->isNovelty = $isNovelty;
  221. return $this;
  222. }
  223. public function getNoveltyExpirationDate(): ?\DateTimeInterface
  224. {
  225. return $this->noveltyExpirationDate;
  226. }
  227. public function setNoveltyExpirationDate(?\DateTimeInterface $noveltyExpirationDate): self
  228. {
  229. $this->noveltyExpirationDate = $noveltyExpirationDate;
  230. return $this;
  231. }
  232. public function getIsOrganic(): ?bool
  233. {
  234. return $this->isOrganic;
  235. }
  236. public function setIsOrganic(?bool $isOrganic): self
  237. {
  238. $this->isOrganic = $isOrganic;
  239. return $this;
  240. }
  241. public function getOrganicLabel(): ?string
  242. {
  243. return $this->organicLabel;
  244. }
  245. public function setOrganicLabel(?string $organicLabel): self
  246. {
  247. $this->organicLabel = $organicLabel;
  248. return $this;
  249. }
  250. }