src/Entity/ProductAttribute.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
  5. /**
  6. * ProductsAttributes
  7. *
  8. * @ORM\Table(name="products_attributes", indexes={@ORM\Index(name="idx_products_id", columns={"products_id"}), @ORM\Index(name="options_id", columns={"options_id"})})
  9. * @ORM\Entity
  10. * @ORM\HasLifecycleCallbacks()
  11. */
  12. class ProductAttribute
  13. {
  14. /**
  15. * @var int
  16. *
  17. * @ORM\Column(name="products_attributes_id", type="integer", nullable=false)
  18. * @ORM\Id
  19. * @ORM\GeneratedValue(strategy="IDENTITY")
  20. */
  21. private $id;
  22. /**
  23. * @var int
  24. *
  25. * @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="attributes")
  26. * @ORM\JoinColumn(name="products_id", referencedColumnName="products_id")
  27. */
  28. private $product;
  29. /**
  30. * @ORM\ManyToOne(targetEntity="App\Entity\ProductOption")
  31. * @ORM\JoinColumn(name="options_id", referencedColumnName="products_options_id")
  32. */
  33. private $option;
  34. /**
  35. * @ORM\ManyToOne(targetEntity="App\Entity\ProductOptionValue")
  36. * @ORM\JoinColumn(name="options_values_id", referencedColumnName="products_options_values_id")
  37. */
  38. private $value;
  39. /**
  40. * @var string
  41. *
  42. * @ORM\Column(name="options_values_price", type="decimal", precision=15, scale=4, nullable=false, options={"default"="0.0000"})
  43. */
  44. private $price = 0;
  45. /**
  46. * @var string
  47. *
  48. * @ORM\Column(name="price_prefix", type="string", length=1, nullable=false, options={"fixed"=true})
  49. */
  50. private $pricePrefix = '';
  51. /**
  52. * @var int
  53. *
  54. * @ORM\Column(name="products_options_sort_order", type="integer", nullable=false)
  55. */
  56. private $optionsSortOrder = 0;
  57. public function getId() {
  58. return $this->id;
  59. }
  60. public function getProduct() {
  61. return $this->product;
  62. }
  63. public function getOption() {
  64. return $this->option;
  65. }
  66. public function getValue() {
  67. return $this->value;
  68. }
  69. public function getPrice() {
  70. return $this->price;
  71. }
  72. public function getPricePrefix() {
  73. return $this->pricePrefix;
  74. }
  75. public function getSortOrder() {
  76. return $this->sortOrder;
  77. }
  78. public function setProduct($product) {
  79. $this->product = $product;
  80. }
  81. public function setOption($option) {
  82. $this->option = $option;
  83. }
  84. public function setValue(\App\Entity\ProductOptionValue $value) {
  85. $this->value = $value;
  86. }
  87. public function setPrice($price) {
  88. $this->price = $price;
  89. }
  90. public function setPricePrefix($pricePrefix) {
  91. $this->pricePrefix = $pricePrefix;
  92. }
  93. public function setSortOrder($optionsSortOrder) {
  94. $this->sortOrder = $optionsSortOrder;
  95. }
  96. /**
  97. * @ORM\PostLoad
  98. *
  99. * @todo Remove once 0 values in the table are converted to NULL.
  100. */
  101. public function postLoad(\Doctrine\ORM\Event\LifecycleEventArgs $args) {
  102. if ($this->value && $this->value->getId() == 0) {
  103. $this->value = null;
  104. }
  105. if ($this->option && $this->option->getId() == 0) {
  106. $this->option = null;
  107. }
  108. }
  109. }