Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ProductModel.php 3.3KB

il y a 3 ans
il y a 3 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Product;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyTrait;
  6. use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface;
  7. use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  10. use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
  11. use Lc\SovBundle\Doctrine\Extension\SortableInterface;
  12. use Lc\SovBundle\Doctrine\Extension\SortableTrait;
  13. use Lc\SovBundle\Doctrine\Extension\StatusTrait;
  14. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  15. /**
  16. * @ORM\MappedSuperclass()
  17. */
  18. abstract class ProductModel extends AbstractLightEntity implements SortableInterface, ProductPropertyInterface,
  19. PriceInterface, ProductInterface
  20. {
  21. use SortableTrait;
  22. use ProductPropertyTrait;
  23. use StatusTrait;
  24. /**
  25. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface", inversedBy="products", cascade={"persist"})
  26. * @ORM\JoinColumn(nullable=false)
  27. */
  28. protected $productFamily;
  29. /**
  30. * @ORM\Column(type="string", length=255, nullable=true)
  31. */
  32. protected $title;
  33. /**
  34. * @ORM\Column(type="boolean", nullable=true)
  35. */
  36. protected $originProduct;
  37. /**
  38. * @ORM\Column(type="string", length=255, nullable=true)
  39. */
  40. protected $exportTitle;
  41. /**
  42. * @ORM\Column(type="text", nullable=true)
  43. */
  44. protected $exportNote;
  45. public function __construct()
  46. {
  47. $this->orderProducts = new ArrayCollection();
  48. $this->status = 1;
  49. }
  50. public function __toString()
  51. {
  52. $title = $this->getProductFamily()->getTitle();
  53. if ($this->getTitle() && strlen($this->getTitle())) {
  54. $title .= ' - ' . $this->getTitle();
  55. }
  56. // @TODO : à remettre en place
  57. /*if ($this->getProductFamily()->hasProductsWithVariousWeight()) {
  58. $title .= ' - ' . $this->getQuantityLabelInherited();
  59. }*/
  60. return $title;
  61. }
  62. public function getProductFamily(): ?ProductFamilyInterface
  63. {
  64. return $this->productFamily;
  65. }
  66. public function setProductFamily(?ProductFamilyInterface $productFamily): self
  67. {
  68. $this->productFamily = $productFamily;
  69. return $this;
  70. }
  71. public function getTitle(): ?string
  72. {
  73. return $this->title;
  74. }
  75. public function setTitle(?string $title): self
  76. {
  77. $this->title = $title;
  78. return $this;
  79. }
  80. public function getOriginProduct(): ?bool
  81. {
  82. return $this->originProduct;
  83. }
  84. public function setOriginProduct(?bool $originProduct): self
  85. {
  86. $this->originProduct = $originProduct;
  87. return $this;
  88. }
  89. public function getExportTitle(): ?string
  90. {
  91. return $this->exportTitle;
  92. }
  93. public function setExportTitle(?string $exportTitle): self
  94. {
  95. $this->exportTitle = $exportTitle;
  96. return $this;
  97. }
  98. public function getExportNote(): ?string
  99. {
  100. return $this->exportNote;
  101. }
  102. public function setExportNote(?string $exportNote): self
  103. {
  104. $this->exportNote = $exportNote;
  105. return $this;
  106. }
  107. }