orderProducts = new ArrayCollection(); $this->status = 1; } public function __toString() { $title = $this->getProductFamily()->getTitle(); if ($this->getTitle() && strlen($this->getTitle())) { $title .= ' - ' . $this->getTitle(); } if ($this->getProductFamily()->hasProductsWithVariousWeight()) { $title .= ' - ' . $this->getQuantityLabelInherited(); } return $title; } // @TODO : move // getProductQuantityMaxAddCart public function getQuantityMaxAddCart(OrderShopInterface $orderShop) { $productFamily = $this->getProductFamily(); $byWeight = false; if ($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE) { $byWeight = true; } return $this->getAvailableQuantityInherited() - $orderShop->getQuantityOrderByProduct($this, $byWeight); } // @TODO : move // getProductQuantity public function getProductQuantity() { $productFamily = $this->getProductFamily(); if ($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE) { return $this->getQuantityInherited() / $this->getUnitInherited()->getCoefficient(); } else { return 1; } } // @TODO : move public function getBuyingPriceInherited() { if ($this->getBuyingPrice()) { return $this->getBuyingPrice(); } else { return $this->getProductFamily()->getBuyingPrice(); } } // @TODO : move public function getBuyingPriceByRefUnitInherited() { if ($this->getBuyingPriceByRefUnit()) { return $this->getBuyingPriceByRefUnit(); } else { return $this->getProductFamily()->getBuyingPriceByRefUnit(); } } // @TODO : move public function getPriceInherited() { if ($this->getPrice()) { return $this->getPrice(); } else { return $this->getProductFamily()->getPrice(); } } // @TODO : move public function getPriceByRefUnitInherited() { if ($this->getPriceByRefUnit()) { return $this->getPriceByRefUnit(); } else { return $this->getProductFamily()->getPriceByRefUnit(); } } // @TODO : move public function getBehaviorPriceInherited() { return $this->getProductFamily()->getBehaviorPrice(); } // @TODO : move public function getReductionCatalogInherited() { return $this->getProductFamily()->getReductionCatalog(); } // @TODO : move public function getUnitInherited() { if ($this->getUnit()) { return $this->getUnit(); } else { return $this->getProductFamily()->getUnit(); } } // @TODO : move public function getTitleInherited() { if ($this->getTitle()) { return $this->getTitle(); } else { return $this->getProductFamily()->getTitle(); } } // @TODO : move public function getQuantityInherited() { if ($this->getQuantity()) { return $this->getQuantity(); } else { return $this->getProductFamily()->getQuantity(); } } // @TODO : move public function getQuantityLabelInherited() { $quantity = $this->getQuantityInherited(); $unit = $this->getUnitInherited(); return $quantity . $unit->getWordingShort(); } // @TODO : move public function getQuantityTitle($productFamily) { $title = $this->getQuantityLabelInherited(); if ($productFamily->hasProductsWithVariousWeight()) { $title .= ', ' . $this->getTitleInherited(); } return $title; } // @TODO : move public function getAvailableQuantityInherited() { switch ($this->getProductFamily()->getBehaviorCountStock()) { case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE : return $this->getProductFamily()->getAvailableQuantity(); break; case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : return $this->getAvailableQuantity(); break; case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_UNLIMITED : return false; break; } } // @TODO : move public function getTaxRateInherited() { return $this->getProductFamily()->getTaxRateInherited(); } public function getProductFamily(): ?ProductFamilyInterface { return $this->productFamily; } public function setProductFamily(?ProductFamilyInterface $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; } public function getOriginProduct(): ?bool { return $this->originProduct; } public function setOriginProduct(?bool $originProduct): self { $this->originProduct = $originProduct; return $this; } public function getExportTitle(): ?string { return $this->exportTitle; } //TODO move public function getExportTitleInherited(): ?string { $exportTitle = $this->getExportTitle(); if ($exportTitle && strlen($exportTitle)) { return $exportTitle; } else { $productFamily = $this->getProductFamily(); if ($productFamily) { return $productFamily->getExportTitle(); } } return null; } public function setExportTitle(?string $exportTitle): self { $this->exportTitle = $exportTitle; return $this; } public function getExportNote(): ?string { return $this->exportNote; } //TODO move public function getExportNoteInherited(): ?string { $exportNote = $this->getExportNote(); if ($exportNote && strlen($exportNote)) { return $exportNote; } else { $productFamily = $this->getProductFamily(); if ($productFamily) { return $productFamily->getExportNote(); } } return null; } public function setExportNote(?string $exportNote): self { $this->exportNote = $exportNote; return $this; } }