Browse Source

Correctif dupplication produit

packProduct
Fabien Normand 3 years ago
parent
commit
d7a8138a48
4 changed files with 26 additions and 7 deletions
  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 View File

return $this->store; return $this->store;
} }




} }

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

{ {


//Récupère le product origin //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) { if (count($originProducts) > 1) {
throw new \ErrorException('Plusieurs OriginProduct pour un même produit... Contacter fab'); throw new \ErrorException('Plusieurs OriginProduct pour un même produit... Contacter fab');

+ 13
- 0
Repository/Product/ProductRepositoryQuery.php View File

} }




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 public function filterAvailableQuantityNegative() :self
{ {



+ 10
- 0
Repository/Product/ProductStore.php View File



namespace Lc\CaracoleBundle\Repository\Product; namespace Lc\CaracoleBundle\Repository\Product;


use App\Entity\Product\ProductFamily;
use App\Solver\Product\ProductFamilySectionPropertySolver; use App\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait; use Lc\CaracoleBundle\Repository\SectionStoreTrait;
} }




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

}
} }

Loading…
Cancel
Save