Преглед изворни кода

Correctif dupplication produit

packProduct
Fabien Normand пре 3 година
родитељ
комит
e6c492fcda
2 измењених фајлова са 33 додато и 31 уклоњено
  1. +32
    -30
      EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php
  2. +1
    -1
      Model/Site/PageModel.php

+ 32
- 30
EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php Прегледај датотеку

@@ -78,44 +78,46 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface
protected function processProducts($entity)
{

//Récupère le product origin
$originProducts = $this->productContainer->getStore()->getOriginByProductFamily($entity);
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 {
if (count($originProducts) == 0) {
$entityClassName = $this->em->getEntityName(ProductInterface::class);
$originProduct = new $entityClassName();
$originProduct->setProductFamily($entity);
$originProduct->setOriginProduct(true);
$entity->addProduct($originProduct);
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);
}
}
}


+ 1
- 1
Model/Site/PageModel.php Прегледај датотеку

@@ -43,7 +43,7 @@ abstract class PageModel extends SovPageModel implements FilterMerchantInterface
return $this->section;
}

public function setSection(SectionInterface $section): self
public function setSection(?SectionInterface $section): self
{
$this->section = $section;


Loading…
Откажи
Сачувај