|
|
@@ -78,50 +78,46 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface |
|
|
|
protected function processProducts($entity) |
|
|
|
{ |
|
|
|
|
|
|
|
//Récupère le product origin |
|
|
|
$originProducts = $this->em->getRepository(ProductInterface::class) |
|
|
|
->findBy( |
|
|
|
array( |
|
|
|
'productFamily' => $entity->getId(), |
|
|
|
'originProduct' => true, |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
if (count($originProducts) > 1) { |
|
|
|
throw new \ErrorException('Plusieurs OriginProduct pour un même produit... Contacter fab'); |
|
|
|
// Case Nouveau product family |
|
|
|
} else { |
|
|
|
if (count($originProducts) == 0) { |
|
|
|
$entityClassName = $this->em->getEntityName(ProductInterface::class); |
|
|
|
$originProduct = new $entityClassName(); |
|
|
|
$originProduct->setProductFamily($entity); |
|
|
|
$originProduct->setOriginProduct(true); |
|
|
|
$entity->addProduct($originProduct); |
|
|
|
if($entity->getId()) { |
|
|
|
//Récupère le product origin |
|
|
|
$originProducts = $this->productContainer->getStore()->getOriginByProductFamily($entity); |
|
|
|
|
|
|
|
if (count($originProducts) > 1) { |
|
|
|
throw new \ErrorException('Plusieurs OriginProduct pour un même produit... Contacter fab'); |
|
|
|
// Case Nouveau product family |
|
|
|
} else { |
|
|
|
$originProduct = $originProducts[0]; |
|
|
|
if (count($originProducts) == 0) { |
|
|
|
$entityClassName = $this->em->getEntityName(ProductInterface::class); |
|
|
|
$originProduct = new $entityClassName(); |
|
|
|
$originProduct->setProductFamily($entity); |
|
|
|
$originProduct->setOriginProduct(true); |
|
|
|
$entity->addProduct($originProduct); |
|
|
|
} else { |
|
|
|
$originProduct = $originProducts[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($entity->getActiveProducts()) { |
|
|
|
$originProduct->setStatus(-1); |
|
|
|
} else { |
|
|
|
$originProduct->setStatus(1); |
|
|
|
} |
|
|
|
if ($entity->getActiveProducts()) { |
|
|
|
$originProduct->setStatus(-1); |
|
|
|
} else { |
|
|
|
$originProduct->setStatus(1); |
|
|
|
} |
|
|
|
|
|
|
|
//Enregistrement |
|
|
|
$entity->addProduct($originProduct); |
|
|
|
//Enregistrement |
|
|
|
$entity->addProduct($originProduct); |
|
|
|
|
|
|
|
foreach ($entity->getProducts() as $product) { |
|
|
|
$product->setProductFamily($entity); |
|
|
|
foreach ($entity->getProducts() as $product) { |
|
|
|
$product->setProductFamily($entity); |
|
|
|
|
|
|
|
if ($entity->getProductsQuantityAsTitle() && $product->getStatus() >= 1) { |
|
|
|
$product->setTitle( |
|
|
|
str_replace('.', ',', $this->productContainer->getSolver()->getQuantityInherited($product)) . $this->productContainer->getSolver()->getUnitInherited($product)->getWording() |
|
|
|
); |
|
|
|
} |
|
|
|
if ($entity->getProductsQuantityAsTitle() && $product->getStatus() >= 1) { |
|
|
|
$product->setTitle( |
|
|
|
str_replace('.', ',', $this->productContainer->getSolver()->getQuantityInherited($product)) . $this->productContainer->getSolver()->getUnitInherited($product)->getWording() |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
$this->em->persist($product); |
|
|
|
$entity->addProduct($product); |
|
|
|
$this->em->persist($product); |
|
|
|
$entity->addProduct($product); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|