Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ProductModel.php 3.3KB

3 anos atrás
3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. if ($this->getProductFamily()->hasProductsWithVariousWeight()) {
  57. $title .= ' - ' . $this->getQuantityLabelInherited();
  58. }
  59. return $title;
  60. }
  61. public function getProductFamily(): ?ProductFamilyInterface
  62. {
  63. return $this->productFamily;
  64. }
  65. public function setProductFamily(?ProductFamilyInterface $productFamily): self
  66. {
  67. $this->productFamily = $productFamily;
  68. return $this;
  69. }
  70. public function getTitle(): ?string
  71. {
  72. return $this->title;
  73. }
  74. public function setTitle(?string $title): self
  75. {
  76. $this->title = $title;
  77. return $this;
  78. }
  79. public function getOriginProduct(): ?bool
  80. {
  81. return $this->originProduct;
  82. }
  83. public function setOriginProduct(?bool $originProduct): self
  84. {
  85. $this->originProduct = $originProduct;
  86. return $this;
  87. }
  88. public function getExportTitle(): ?string
  89. {
  90. return $this->exportTitle;
  91. }
  92. public function setExportTitle(?string $exportTitle): self
  93. {
  94. $this->exportTitle = $exportTitle;
  95. return $this;
  96. }
  97. public function getExportNote(): ?string
  98. {
  99. return $this->exportNote;
  100. }
  101. public function setExportNote(?string $exportNote): self
  102. {
  103. $this->exportNote = $exportNote;
  104. return $this;
  105. }
  106. }