|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use App\Entity\OrderProductReductionCatalog;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\ShopBundle\Context\PriceInterface;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class OrderProduct implements PriceInterface
- {
- use PriceTrait ;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderProducts", cascade={"persist"})
- * @ORM\JoinColumn(nullable=false)
- */
- protected $orderShop;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductInterface", inversedBy="orderProducts"))
- */
- protected $product;
-
- /**
- * @ORM\Column(type="integer")
- */
- protected $quantityOrder;
-
- /**
- * @ORM\Column(type="float")
- */
- protected $quantityProduct;
-
- /**
- * @ORM\Column(type="string", length=255)
- */
- protected $title;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderProductReductionCatalogInterface", cascade={"persist", "remove"})
- */
- protected $orderProductReductionCatalog;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderProductRefundInterface", mappedBy="orderProduct", cascade={"persist", "remove"})
- */
- protected $orderProductRefund;
-
- public function __toString()
- {
- if($this->getTitle()) {
- return $this->getTitle();
- }
- else{
- return $this->getProduct()->getProductFamily()->getTitle(). ' - '.$this->getProduct()->getTitle();
- }
- }
-
- public function getTitleOrderShop()
- {
- $product = $this->getProduct() ;
- $productFamily = $product->getProductFamily() ;
-
- $titleProduct = $product->getTitle() ;
- $titleProductFamily = $productFamily->getTitle() ;
-
- if(strlen($titleProduct) > 0 && strlen($titleProductFamily) > 0) {
- $title = $titleProductFamily.' - '.$titleProduct ;
- }
- else {
- $title = strlen($titleProduct) ? $titleProduct : $titleProductFamily ;
- }
-
- if($productFamily->hasProductsWithVariousWeight()) {
- $title .= ' - '.$product->getQuantityLabelInherited() ;
- }
-
- return $title ;
- }
-
- public function getTitleSummaryAfterAddCart()
- {
- $title = '' ;
-
- $product = $this->getProduct() ;
- $productFamily = $product->getProductFamily() ;
- $titleProduct = $product->getTitleInherited() ;
- $titleProductFamily = $productFamily->getTitle() ;
-
- // multiple
- if($productFamily->getActiveProducts() && $productFamily->getBehaviorAddToCart() == 'multiple') {
- $title .= $titleProduct ;
- if($productFamily->hasProductsWithVariousWeight()) {
- $title .= ' - '.$product->getQuantityLabelInherited() ;
- }
- }
-
- // simple
- if($productFamily->getBehaviorAddToCart() == 'simple') {
- if($productFamily->getActiveProducts()) {
- $title .= $titleProduct ;
- if($productFamily->hasProductsWithVariousWeight()) {
- $title .= ' - '.$product->getQuantityLabelInherited() ;
- }
- }
- }
-
- return $title ;
- }
-
- public function getOrderShop(): ?OrderShop
- {
- return $this->orderShop;
- }
-
- public function setOrderShop(?OrderShop $orderShop): self
- {
- $this->orderShop = $orderShop;
-
- return $this;
- }
-
- public function getProduct(): ?Product
- {
- return $this->product;
- }
-
- public function setProduct(?Product $product): self
- {
- $this->product = $product;
-
- return $this;
- }
-
- public function getQuantityOrder(): ?int
- {
- return $this->quantityOrder;
- }
-
- public function setQuantityOrder(int $quantityOrder): self
- {
- $this->quantityOrder = $quantityOrder;
-
- return $this;
- }
-
- public function getQuantityProduct(): ?float
- {
- return $this->quantityProduct;
- }
-
- public function setQuantityProduct(float $quantityProduct): self
- {
- $this->quantityProduct = $quantityProduct;
-
- return $this;
- }
-
- public function getTitle(): ?string
- {
- return $this->title;
- }
-
- public function setTitle(string $title): self
- {
- $this->title = $title;
-
- return $this;
- }
-
- public function getOrderProductReductionCatalog(): ?OrderProductReductionCatalog
- {
- return $this->orderProductReductionCatalog;
- }
-
- public function setOrderProductReductionCatalog(?OrderProductReductionCatalog $orderProductReductionCatalog): self
- {
- $this->orderProductReductionCatalog = $orderProductReductionCatalog;
-
- return $this;
- }
- public function getOrderProductRefund(): ?OrderProductRefund
- {
- return $this->orderProductRefund;
- }
-
- public function setOrderProductRefund(OrderProductRefund $orderProductRefund): self
- {
- $this->orderProductRefund = $orderProductRefund;
-
- // set the owning side of the relation if necessary
- if ($orderProductRefund->getOrderProduct() !== $this) {
- $orderProductRefund->setOrderProduct($this);
- }
-
- return $this;
- }
-
- }
|