Sfoglia il codice sorgente

Correctif dupplication produit

packProduct
Fabien Normand 3 anni fa
parent
commit
d7a8138a48
4 ha cambiato i file con 26 aggiunte e 7 eliminazioni
  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 Vedi File

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



}

+ 1
- 7
EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php Vedi File

@@ -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 Vedi File

@@ -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 Vedi File

@@ -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();

}
}

Loading…
Annulla
Salva