Browse Source

Bug [Backend] Duplication fiche sur un autre marchand #204

develop
Fab 1 year ago
parent
commit
a5e2f640a3
2 changed files with 10 additions and 9 deletions
  1. +8
    -7
      Controller/AdminControllerTrait.php
  2. +2
    -2
      EventSubscriber/Address/DuplicateAddressEventSubscriber.php

+ 8
- 7
Controller/AdminControllerTrait.php View File

@@ -128,9 +128,9 @@ trait AdminControllerTrait

if ($duplicateOtherMerchantForm->isSubmitted() && $duplicateOtherMerchantForm->isValid()) {
$newEntity = $entityComponent->duplicateEntity($context->getEntity()->getInstance());
$entityManager->create($newEntity);
$merchant = $duplicateOtherMerchantForm->get('merchants')->getData();

$merchant = $duplicateOtherMerchantForm->get('merchants')->getData();
//
if($this->isInstanceOf(ProductFamilyInterface::class)) {
$sectionStore = $this->getSectionContainer()->getStore()->setMerchant($merchant);

@@ -158,12 +158,13 @@ trait AdminControllerTrait
}

$newEntity->initProductCategories();
}
}
else {
$newEntity->setMerchant($merchant);
}

$entityManager->update($newEntity);
//
//
$entityManager->create($newEntity, false);
$entityManager->flush();

$url = $this->get(AdminUrlGenerator::class)
@@ -230,10 +231,10 @@ trait AdminControllerTrait

if ($duplicateOtherSectionForm->isSubmitted() && $duplicateOtherSectionForm->isValid()) {
$newEntity = $entityComponent->duplicateEntity($context->getEntity()->getInstance());
$em->create($newEntity);
$em->create($newEntity, false);
$section = $duplicateOtherSectionForm->get('sections')->getData();
$newEntity->setSection($section);
$em->update($newEntity);
$em->update($newEntity, false);
$em->flush();

$url = $this->get(AdminUrlGenerator::class)

+ 2
- 2
EventSubscriber/Address/DuplicateAddressEventSubscriber.php View File

@@ -45,7 +45,7 @@ class DuplicateAddressEventSubscriber implements EventSubscriberInterface
if(method_exists($entity, $methodGet) && method_exists($entity, $methodSet)){
$newAddress = clone $entity->$methodGet();
$entity->$methodSet($newAddress);
$this->em->persist($newAddress);
$this->em->create($newAddress, false);
}
}

@@ -53,4 +53,4 @@ class DuplicateAddressEventSubscriber implements EventSubscriberInterface
}


}
}

Loading…
Cancel
Save