Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

146 lines
3.5KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Order;
  3. use Lc\CaracoleBundle\Doctrine\Extension\PriceTrait;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface;
  6. use Lc\CaracoleBundle\Model\Product\ProductInterface;
  7. use Lc\SovBundle\Doctrine\EntityInterface;
  8. /**
  9. * @ORM\MappedSuperclass()
  10. */
  11. abstract class OrderProductModel implements PriceInterface, EntityInterface
  12. {
  13. use PriceTrait;
  14. /**
  15. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", inversedBy="orderProducts", cascade={"persist"})
  16. * @ORM\JoinColumn(nullable=false)
  17. */
  18. protected $orderShop;
  19. /**
  20. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Product\ProductInterface"))
  21. */
  22. protected $product;
  23. /**
  24. * @ORM\Column(type="integer")
  25. */
  26. protected $quantityOrder;
  27. /**
  28. * @ORM\Column(type="float")
  29. */
  30. protected $quantityProduct;
  31. /**
  32. * @ORM\Column(type="string", length=255)
  33. */
  34. protected $title;
  35. /**
  36. * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderProductReductionCatalogInterface", cascade={"persist", "remove"})
  37. */
  38. protected $orderProductReductionCatalog;
  39. public function __toString()
  40. {
  41. if ($this->getTitle()) {
  42. return $this->getTitle();
  43. } else {
  44. return $this->getProduct()->getProductFamily()->getTitle() . ' - ' . $this->getProduct()->getTitle();
  45. }
  46. }
  47. // isOrderProductAvailable
  48. /*public function isAvailable()
  49. {
  50. return $this->getProduct()->isAvailable($this->getQuantityOrder());
  51. }*/
  52. // isOrderProductAvailableAddCart
  53. // @TODO : à remettre en place si nécessaire
  54. /*public function isAvailableAddCart(OrderShopInterface $orderShop = null)
  55. {
  56. $product = $this->getProduct();
  57. return $this->isProductAvailable($product, $this->getQuantityOrder(), true, $orderShop);
  58. }*/
  59. public function getOrderShop(): ?OrderShopInterface
  60. {
  61. return $this->orderShop;
  62. }
  63. public function setOrderShop(?OrderShopInterface $orderShop): self
  64. {
  65. $this->orderShop = $orderShop;
  66. return $this;
  67. }
  68. public function getProduct(): ?ProductInterface
  69. {
  70. return $this->product;
  71. }
  72. public function setProduct(?ProductInterface $product): self
  73. {
  74. $this->product = $product;
  75. return $this;
  76. }
  77. public function getQuantityOrder(): ?int
  78. {
  79. return $this->quantityOrder;
  80. }
  81. public function setQuantityOrder(int $quantityOrder): self
  82. {
  83. $this->quantityOrder = $quantityOrder;
  84. return $this;
  85. }
  86. public function getQuantityProduct(): ?float
  87. {
  88. return $this->quantityProduct;
  89. }
  90. public function setQuantityProduct(float $quantityProduct): self
  91. {
  92. $this->quantityProduct = $quantityProduct;
  93. return $this;
  94. }
  95. public function getTitle(): ?string
  96. {
  97. return $this->title;
  98. }
  99. public function setTitle(string $title): self
  100. {
  101. $this->title = $title;
  102. return $this;
  103. }
  104. public function getOrderProductReductionCatalog(): ?OrderProductReductionCatalogInterface
  105. {
  106. return $this->orderProductReductionCatalog;
  107. }
  108. public function setOrderProductReductionCatalog(?OrderProductReductionCatalogInterface $orderProductReductionCatalog): self
  109. {
  110. $this->orderProductReductionCatalog = $orderProductReductionCatalog;
  111. return $this;
  112. }
  113. }