46 lines
837 B
PHP
46 lines
837 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KupShop\SalesBundle\Entity;
|
|
|
|
use KupShop\KupShopBundle\Util\Price\Price;
|
|
|
|
class SaleItem
|
|
{
|
|
public int $id;
|
|
|
|
public ?int $productId = null;
|
|
|
|
public ?int $variationId = null;
|
|
|
|
public float $pieces;
|
|
|
|
public Price $piecePrice;
|
|
|
|
public Price $totalPrice;
|
|
|
|
public string $name;
|
|
|
|
public array $data;
|
|
|
|
private ?\Product $product = null;
|
|
|
|
public function setProduct(?\Product $product): self
|
|
{
|
|
$this->product = $product;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getProduct(): ?\Product
|
|
{
|
|
if (!$this->product && $this->productId) {
|
|
$this->product = \Variation::createProductOrVariation($this->productId, $this->variationId);
|
|
$this->product->createFromDB();
|
|
}
|
|
|
|
return $this->product;
|
|
}
|
|
}
|