|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\ShopBundle\Context\OrderProductInterface;
- use Lc\ShopBundle\Context\PriceInterface;
- use Lc\ShopBundle\Context\ProductInterface;
- use Lc\ShopBundle\Context\ProductPropertyInterface;
- use Lc\ShopBundle\Context\SortableInterface;
- use Lc\ShopBundle\Services\Price;
-
-
- abstract class Product extends AbstractEntity implements SortableInterface, ProductPropertyInterface, PriceInterface
- {
- use SortableTrait;
- use ProductPropertyTrait;
-
-
-
- protected $productFamily;
-
-
-
- protected $title;
-
-
- public function __construct()
- {
- $this->orderProducts = new ArrayCollection() ;
- }
-
- public function getBuyingPriceInherited()
- {
- if($this->getBuyingPrice()) {
- return $this->getBuyingPrice();
- }
- else {
- return $this->getProductFamily()->getBuyingPrice();
- }
- }
-
- public function getBuyingPriceByRefUnitInherited()
- {
- if($this->getBuyingPriceByRefUnit()) {
- return $this->getBuyingPriceByRefUnit();
- }
- else {
- return $this->getProductFamily()->getBuyingPriceByRefUnit();
- }
- }
-
- public function getPriceInherited()
- {
- if($this->getPrice()) {
- return $this->getPrice();
- }
- else {
- return $this->getProductFamily()->getPrice();
- }
- }
-
- public function getPriceByRefUnitInherited()
- {
- if($this->getPriceByRefUnit()) {
- return $this->getPriceByRefUnit();
- }
- else {
- return $this->getProductFamily()->getPriceByRefUnit();
- }
- }
-
- public function getBehaviorPriceInherited()
- {
- return $this->getProductFamily()->getBehaviorPrice() ;
- }
-
- public function getReductionCatalogInherited()
- {
- return $this->getProductFamily()->getReductionCatalog() ;
- }
-
- public function getUnitInherited()
- {
- if($this->getUnit()) {
- return $this->getUnit();
- }
- else {
- return $this->getProductFamily()->getUnit();
- }
- }
-
- public function getTitleInherited()
- {
- if($this->getTitle()){
- return $this->getTitle();
- }
- else{
- return $this->getProductFamily()->getTitle();
- }
- }
-
- public function getQuantityInherited()
- {
- if($this->getQuantity()) {
- return $this->getQuantity();
- }
- else{
- return $this->getProductFamily()->getQuantity();
- }
- }
-
- public function getQuantityLabelInherited()
- {
- $quantity = $this->getQuantityInherited() ;
- $unit = $this->getUnitInherited() ;
- return $quantity.$unit->getWordingShort() ;
- }
-
- public function getQuantityTitle($productFamily)
- {
- $title = $this->getQuantityLabelInherited() ;
- if($productFamily->hasProductsWithVariousWeight()) {
- $title .= ', '.$this->getTitleInherited() ;
- }
- return $title ;
- }
-
- public function getAvailableQuantityInherited()
- {
- if($this->getProductFamily()->getBehaviorCountStock()) {
- return $this->getAvailableQuantity();
- }
- else {
- return $this->getProductFamily()->getAvailableQuantity();
- }
- }
-
- public function getTaxRateInherited()
- {
- return $this->getProductFamily()->getTaxRateInherited();
- }
-
- public function getProductFamily(): ?ProductFamily
- {
- return $this->productFamily;
- }
-
- public function setProductFamily(?ProductFamily $productFamily): self
- {
- $this->productFamily = $productFamily;
-
- return $this;
- }
-
- public function getTitle(): ?string
- {
- return $this->title;
- }
-
- public function setTitle(?string $title): self
- {
- $this->title = $title;
-
- return $this;
- }
- }
|