<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
/**
* ProductsAttributes
*
* @ORM\Table(name="products_attributes", indexes={@ORM\Index(name="idx_products_id", columns={"products_id"}), @ORM\Index(name="options_id", columns={"options_id"})})
* @ORM\Entity
* @ORM\HasLifecycleCallbacks()
*/
class ProductAttribute
{
/**
* @var int
*
* @ORM\Column(name="products_attributes_id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var int
*
* @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="attributes")
* @ORM\JoinColumn(name="products_id", referencedColumnName="products_id")
*/
private $product;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ProductOption")
* @ORM\JoinColumn(name="options_id", referencedColumnName="products_options_id")
*/
private $option;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ProductOptionValue")
* @ORM\JoinColumn(name="options_values_id", referencedColumnName="products_options_values_id")
*/
private $value;
/**
* @var string
*
* @ORM\Column(name="options_values_price", type="decimal", precision=15, scale=4, nullable=false, options={"default"="0.0000"})
*/
private $price = 0;
/**
* @var string
*
* @ORM\Column(name="price_prefix", type="string", length=1, nullable=false, options={"fixed"=true})
*/
private $pricePrefix = '';
/**
* @var int
*
* @ORM\Column(name="products_options_sort_order", type="integer", nullable=false)
*/
private $optionsSortOrder = 0;
public function getId() {
return $this->id;
}
public function getProduct() {
return $this->product;
}
public function getOption() {
return $this->option;
}
public function getValue() {
return $this->value;
}
public function getPrice() {
return $this->price;
}
public function getPricePrefix() {
return $this->pricePrefix;
}
public function getSortOrder() {
return $this->sortOrder;
}
public function setProduct($product) {
$this->product = $product;
}
public function setOption($option) {
$this->option = $option;
}
public function setValue(\App\Entity\ProductOptionValue $value) {
$this->value = $value;
}
public function setPrice($price) {
$this->price = $price;
}
public function setPricePrefix($pricePrefix) {
$this->pricePrefix = $pricePrefix;
}
public function setSortOrder($optionsSortOrder) {
$this->sortOrder = $optionsSortOrder;
}
/**
* @ORM\PostLoad
*
* @todo Remove once 0 values in the table are converted to NULL.
*/
public function postLoad(\Doctrine\ORM\Event\LifecycleEventArgs $args) {
if ($this->value && $this->value->getId() == 0) {
$this->value = null;
}
if ($this->option && $this->option->getId() == 0) {
$this->option = null;
}
}
}