return $this->store; | return $this->store; | ||||
} | } | ||||
} | } |
{ | { | ||||
//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'); |
} | } | ||||
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 | ||||
{ | { | ||||
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(); | |||||
} | |||||
} | } |