|
|
|
|
|
|
|
|
public function createProductDistribution(Distribution $distribution, Product $product): ProductDistribution |
|
|
public function createProductDistribution(Distribution $distribution, Product $product): ProductDistribution |
|
|
{ |
|
|
{ |
|
|
$productDistribution = $this->instanciateProductDistribution($distribution, $product); |
|
|
$productDistribution = $this->instanciateProductDistribution($distribution, $product); |
|
|
|
|
|
|
|
|
$this->initActive($productDistribution); |
|
|
|
|
|
$this->initQuantityMax($productDistribution); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->initProductDistribution($productDistribution); |
|
|
$this->saveCreate($productDistribution); |
|
|
$this->saveCreate($productDistribution); |
|
|
|
|
|
|
|
|
return $productDistribution; |
|
|
return $productDistribution; |
|
|
|
|
|
|
|
|
return $this->productDistributionRepository->findOneProductDistribution($distribution, $product) |
|
|
return $this->productDistributionRepository->findOneProductDistribution($distribution, $product) |
|
|
?? $this->createProductDistribution($distribution, $product); |
|
|
?? $this->createProductDistribution($distribution, $product); |
|
|
} |
|
|
} |
|
|
|
|
|
public function updateProductDistribution(ProductDistribution $productDistribution): ProductDistribution |
|
|
|
|
|
{ |
|
|
|
|
|
$this->initProductDistribution($productDistribution); |
|
|
|
|
|
$this->saveUpdate($productDistribution); |
|
|
|
|
|
|
|
|
|
|
|
return $productDistribution; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function initProductDistribution(ProductDistribution $productDistribution): ProductDistribution |
|
|
|
|
|
{ |
|
|
|
|
|
$this->initActive($productDistribution); |
|
|
|
|
|
$this->initQuantityMax($productDistribution); |
|
|
|
|
|
|
|
|
|
|
|
return $productDistribution; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function initActive(ProductDistribution $productDistribution): ProductDistribution |
|
|
public function initActive(ProductDistribution $productDistribution): ProductDistribution |
|
|
{ |
|
|
{ |