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.

283 lines
7.1KB

  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\ProductInterface;
  7. /**
  8. * @ORM\MappedSuperclass()
  9. */
  10. abstract class ProductFamily extends AbstractDocumentEntity
  11. {
  12. /**
  13. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
  14. * @ORM\JoinColumn(nullable=false)
  15. */
  16. protected $merchant;
  17. /**
  18. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", inversedBy="productFamilies")
  19. */
  20. protected $productCategories;
  21. /**
  22. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductInterface", mappedBy="productFamily", orphanRemoval=true, cascade={"persist"})
  23. */
  24. protected $products;
  25. /**
  26. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
  27. * @ORM\JoinColumn(nullable=true)
  28. */
  29. protected $taxRate;
  30. /**
  31. * @ORM\Column(type="float", nullable=true)
  32. */
  33. protected $price;
  34. /**
  35. * @ORM\Column(type="string", length=31, nullable=true)
  36. */
  37. protected $unit;
  38. /**
  39. * @ORM\Column(type="float", nullable=true)
  40. */
  41. protected $step;
  42. /**
  43. * @ORM\Column(type="float", nullable=true)
  44. */
  45. protected $weight;
  46. /**
  47. * @ORM\Column(type="float", nullable=true)
  48. */
  49. protected $stock;
  50. /**
  51. * @ORM\Column(type="float", nullable=true)
  52. */
  53. protected $availableQuantity;
  54. /**
  55. * @ORM\Column(type="string", length=31, nullable=true)
  56. */
  57. protected $behaviorOutOfStock;
  58. /**
  59. * @ORM\Column(type="string", length=31)
  60. */
  61. protected $behaviorCountStock;
  62. /**
  63. * @ORM\Column(type="boolean")
  64. */
  65. protected $activeProducts;
  66. public function __construct()
  67. {
  68. $this->productCategories = new ArrayCollection();
  69. $this->products = new ArrayCollection();
  70. }
  71. public function getMerchant(): ?Merchant
  72. {
  73. return $this->merchant;
  74. }
  75. public function setMerchant(?Merchant $merchant): self
  76. {
  77. $this->merchant = $merchant;
  78. return $this;
  79. }
  80. /**
  81. * @return Collection|ProductInterface[]
  82. */
  83. public function getProducts(): Collection
  84. {
  85. return $this->products;
  86. }
  87. public function addProduct(ProductInterface $product): self
  88. {
  89. if (!$this->products->contains($product)) {
  90. $this->products[] = $product;
  91. $product->setProductFamily($this);
  92. }
  93. return $this;
  94. }
  95. public function removeProduct(ProductInterface $product): self
  96. {
  97. if ($this->products->contains($product)) {
  98. $this->products->removeElement($product);
  99. // set the owning side to null (unless already changed)
  100. if ($product->getProductFamily() === $this) {
  101. $product->setProductFamily(null);
  102. }
  103. }
  104. return $this;
  105. }
  106. /**
  107. * @return Collection|ProductCategory[]
  108. */
  109. public function getProductCategories(): Collection
  110. {
  111. return $this->productCategories;
  112. }
  113. public function initProductCategories()
  114. {
  115. $this->productCategories = new ArrayCollection() ;
  116. }
  117. public function addProductCategory(ProductCategory $productCategory): self
  118. {
  119. if (!$this->productCategories->contains($productCategory)) {
  120. $this->productCategories[] = $productCategory;
  121. }
  122. return $this;
  123. }
  124. public function removeProductCategory(ProductCategory $productCategory): self
  125. {
  126. if ($this->productCategories->contains($productCategory)) {
  127. $this->productCategories->removeElement($productCategory);
  128. }
  129. return $this;
  130. }
  131. public function getTaxRate(): ?TaxRate
  132. {
  133. return $this->taxRate;
  134. }
  135. public function setTaxRate(?TaxRate $taxRate): self
  136. {
  137. $this->taxRate = $taxRate;
  138. return $this;
  139. }
  140. public function getUnit(): ?string
  141. {
  142. return $this->unit;
  143. }
  144. public function setUnit(?string $unit): self
  145. {
  146. $this->unit = $unit;
  147. return $this;
  148. }
  149. public function getPrice(): ?float
  150. {
  151. return $this->price;
  152. }
  153. public function setPrice(?float $price): self
  154. {
  155. $this->price = $price;
  156. return $this;
  157. }
  158. public function getStep(): ?float
  159. {
  160. return $this->step;
  161. }
  162. public function setStep(?float $step): self
  163. {
  164. $this->step = $step;
  165. return $this;
  166. }
  167. public function getWeight(): ?float
  168. {
  169. return $this->weight;
  170. }
  171. public function setWeight(?float $weight): self
  172. {
  173. $this->weight = $weight;
  174. return $this;
  175. }
  176. public function getStock(): ?float
  177. {
  178. return $this->stock;
  179. }
  180. public function setStock(?float $stock): self
  181. {
  182. $this->stock = $stock;
  183. return $this;
  184. }
  185. public function getAvailableQuantity(): ?float
  186. {
  187. return $this->availableQuantity;
  188. }
  189. public function setAvailableQuantity(?float $availableQuantity): self
  190. {
  191. $this->availableQuantity = $availableQuantity;
  192. return $this;
  193. }
  194. public function getBehaviorOutOfStock(): ?string
  195. {
  196. return $this->behaviorOutOfStock;
  197. }
  198. public function setBehaviorOutOfStock(?string $behaviorOutOfStock): self
  199. {
  200. $this->behaviorOutOfStock = $behaviorOutOfStock;
  201. return $this;
  202. }
  203. public function getBehaviorCountStock(): ?string
  204. {
  205. return $this->behaviorCountStock;
  206. }
  207. public function setBehaviorCountStock(string $behaviorCountStock): self
  208. {
  209. $this->behaviorCountStock = $behaviorCountStock;
  210. return $this;
  211. }
  212. public function getActiveProducts(): ?bool
  213. {
  214. return $this->activeProducts;
  215. }
  216. public function setActiveProducts(bool $activeProducts): self
  217. {
  218. $this->activeProducts = $activeProducts;
  219. return $this;
  220. }
  221. }