Explorar el Código

Correctif dupplication produit

packProduct
Fabien Normand hace 3 años
padre
commit
d7a8138a48
Se han modificado 4 ficheros con 26 adiciones y 7 borrados
  1. +2
    -0
      Container/Product/ProductContainer.php
  2. +1
    -7
      EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php
  3. +13
    -0
      Repository/Product/ProductRepositoryQuery.php
  4. +10
    -0
      Repository/Product/ProductStore.php

+ 2
- 0
Container/Product/ProductContainer.php Ver fichero

@@ -48,4 +48,6 @@ class ProductContainer
return $this->store;
}



}

+ 1
- 7
EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php Ver fichero

@@ -79,13 +79,7 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface
{

//Récupère le product origin
$originProducts = $this->em->getRepository(ProductInterface::class)
->findBy(
array(
'productFamily' => $entity->getId(),
'originProduct' => true,
)
);
$originProducts = $this->productContainer->getStore()->getOriginByProductFamily($entity);

if (count($originProducts) > 1) {
throw new \ErrorException('Plusieurs OriginProduct pour un même produit... Contacter fab');

+ 13
- 0
Repository/Product/ProductRepositoryQuery.php Ver fichero

@@ -95,6 +95,19 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery
}


public function filterIsOriginProduct():self
{
$this->andWhere('.originProduct = 1');
return $this;
}


public function filterByProductFamily(ProductFamilyInterface $productFamily): self
{
return $this->andWhereEqual('productFamily', $productFamily);
}


public function filterAvailableQuantityNegative() :self
{


+ 10
- 0
Repository/Product/ProductStore.php Ver fichero

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Repository\Product;

use App\Entity\Product\ProductFamily;
use App\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
@@ -77,4 +78,13 @@ class ProductStore extends AbstractStore
}


public function getOriginByProductFamily(ProductFamily $productFamily, ProductRepositoryQuery $query = null): array
{
$query = $this->createQuery();
$query->filterByProductFamily($productFamily);
$query->filterIsOriginProduct();
$query->filterIsOnlineAndOffline();
return $query->find();

}
}

Cargando…
Cancelar
Guardar