modules/CDev/Coupons/src/Model/CouponProduct.php line 23

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
  4.  * See https://www.x-cart.com/license-agreement.html for license details.
  5.  */
  6. namespace CDev\Coupons\Model;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use XLite\Model\Product as ProductEntity;
  9. /**
  10.  * Category
  11.  *
  12.  * @ORM\Entity
  13.  * @ORM\Table (name="coupon_products",
  14.  *      uniqueConstraints={
  15.  *          @ORM\UniqueConstraint (name="pair", columns={"coupon_id","product_id"})
  16.  *      },
  17.  * )
  18.  */
  19. class CouponProduct extends \XLite\Model\AEntity
  20. {
  21.     /**
  22.      * Primary key
  23.      *
  24.      * @var integer
  25.      *
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue (strategy="AUTO")
  28.      * @ORM\Column         (type="integer", options={ "unsigned": true })
  29.      */
  30.     protected $id;
  31.     /**
  32.      * Relation to a coupon entity
  33.      *
  34.      * @var \CDev\Coupons\Model\Coupon
  35.      *
  36.      * @ORM\ManyToOne  (targetEntity="CDev\Coupons\Model\Coupon", inversedBy="couponProducts")
  37.      * @ORM\JoinColumn (name="coupon_id", referencedColumnName="id", onDelete="CASCADE")
  38.      */
  39.     protected $coupon;
  40.     /**
  41.      * Relation to a product entity
  42.      *
  43.      * @var ProductEntity
  44.      *
  45.      * @ORM\ManyToOne  (targetEntity="XLite\Model\Product", inversedBy="couponProducts")
  46.      * @ORM\JoinColumn (name="product_id", referencedColumnName="product_id", onDelete="CASCADE")
  47.      */
  48.     protected $product;
  49.     /**
  50.      * @return int
  51.      */
  52.     public function getId()
  53.     {
  54.         return $this->id;
  55.     }
  56.     /**
  57.      * @return Coupon|null
  58.      */
  59.     public function getCoupon(): ?Coupon
  60.     {
  61.         return $this->coupon;
  62.     }
  63.     /**
  64.      * @param Coupon $coupon
  65.      */
  66.     public function setCoupon($coupon): CouponProduct
  67.     {
  68.         $this->coupon $coupon;
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return ProductEntity
  73.      */
  74.     public function getProduct(): ?ProductEntity
  75.     {
  76.         return $this->product;
  77.     }
  78.     /**
  79.      * @param ProductEntity|null $product
  80.      */
  81.     public function setProduct(?ProductEntity $product): CouponProduct
  82.     {
  83.         $this->product $product;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return string
  88.      */
  89.     public function getProductName()
  90.     {
  91.         return $this->getProduct()->getName();
  92.     }
  93.     /**
  94.      * @return float
  95.      */
  96.     public function getProductPrice()
  97.     {
  98.         return $this->getProduct()->getPrice();
  99.     }
  100.     /**
  101.      * @return string
  102.      */
  103.     public function getProductSku()
  104.     {
  105.         return $this->getProduct()->getSku();
  106.     }
  107.     /**
  108.      * @return int
  109.      */
  110.     public function getProductAmount()
  111.     {
  112.         return $this->getProduct()->getAmount();
  113.     }
  114. }