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.

261 lines
6.5KB

  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="App\Entity\Product", mappedBy="productFamily", orphanRemoval=true)
  23. */
  24. private $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. public function __construct()
  63. {
  64. $this->productCategories = new ArrayCollection();
  65. $this->products = new ArrayCollection();
  66. }
  67. public function getMerchant(): ?Merchant
  68. {
  69. return $this->merchant;
  70. }
  71. public function setMerchant(?Merchant $merchant): self
  72. {
  73. $this->merchant = $merchant;
  74. return $this;
  75. }
  76. /**
  77. * @return Collection|ProductInterface[]
  78. */
  79. public function getProducts(): Collection
  80. {
  81. return $this->products;
  82. }
  83. public function addProduct(ProductInterface $product): self
  84. {
  85. if (!$this->products->contains($product)) {
  86. $this->products[] = $product;
  87. $product->setProductFamily($this);
  88. }
  89. return $this;
  90. }
  91. public function removeProduct(ProductInterface $product): self
  92. {
  93. if ($this->products->contains($product)) {
  94. $this->products->removeElement($product);
  95. // set the owning side to null (unless already changed)
  96. if ($product->getProductFamily() === $this) {
  97. $product->setProductFamily(null);
  98. }
  99. }
  100. return $this;
  101. }
  102. /**
  103. * @return Collection|ProductCategory[]
  104. */
  105. public function getProductCategories(): Collection
  106. {
  107. return $this->productCategories;
  108. }
  109. public function addProductCategory(ProductCategory $productCategory): self
  110. {
  111. if (!$this->productCategories->contains($productCategory)) {
  112. $this->productCategories[] = $productCategory;
  113. }
  114. return $this;
  115. }
  116. public function removeProductCategory(ProductCategory $productCategory): self
  117. {
  118. if ($this->productCategories->contains($productCategory)) {
  119. $this->productCategories->removeElement($productCategory);
  120. }
  121. return $this;
  122. }
  123. public function getTaxRate(): ?TaxRate
  124. {
  125. return $this->taxRate;
  126. }
  127. public function setTaxRate(?TaxRate $taxRate): self
  128. {
  129. $this->taxRate = $taxRate;
  130. return $this;
  131. }
  132. public function getUnit(): ?string
  133. {
  134. return $this->unit;
  135. }
  136. public function setUnit(?string $unit): self
  137. {
  138. $this->unit = $unit;
  139. return $this;
  140. }
  141. public function getPrice(): ?float
  142. {
  143. return $this->price;
  144. }
  145. public function setPrice(?float $price): self
  146. {
  147. $this->price = $price;
  148. return $this;
  149. }
  150. public function getStep(): ?float
  151. {
  152. return $this->step;
  153. }
  154. public function setStep(?float $step): self
  155. {
  156. $this->step = $step;
  157. return $this;
  158. }
  159. public function getWeight(): ?float
  160. {
  161. return $this->weight;
  162. }
  163. public function setWeight(?float $weight): self
  164. {
  165. $this->weight = $weight;
  166. return $this;
  167. }
  168. public function getStock(): ?float
  169. {
  170. return $this->stock;
  171. }
  172. public function setStock(?float $stock): self
  173. {
  174. $this->stock = $stock;
  175. return $this;
  176. }
  177. public function getAvailableQuantity(): ?float
  178. {
  179. return $this->availableQuantity;
  180. }
  181. public function setAvailableQuantity(?float $availableQuantity): self
  182. {
  183. $this->availableQuantity = $availableQuantity;
  184. return $this;
  185. }
  186. public function getBehaviorOutOfStock(): ?string
  187. {
  188. return $this->behaviorOutOfStock;
  189. }
  190. public function setBehaviorOutOfStock(?string $behaviorOutOfStock): self
  191. {
  192. $this->behaviorOutOfStock = $behaviorOutOfStock;
  193. return $this;
  194. }
  195. public function getBehaviorCountStock(): ?string
  196. {
  197. return $this->behaviorCountStock;
  198. }
  199. public function setBehaviorCountStock(string $behaviorCountStock): self
  200. {
  201. $this->behaviorCountStock = $behaviorCountStock;
  202. return $this;
  203. }
  204. }