foreach ($entity->getActions() as $action){ | foreach ($entity->getActions() as $action){ | ||||
if($action->getName() == ActionDefinition::SWITCH_USER){ | if($action->getName() == ActionDefinition::SWITCH_USER){ | ||||
$sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault(); | $sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault(); | ||||
dump($sectionDefault); | |||||
$url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault->getSlug())); | $url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault->getSlug())); | ||||
$action->setLinkUrl($url); | $action->setLinkUrl($url); | ||||
} | } |
namespace Lc\CaracoleBundle\Repository\Order; | namespace Lc\CaracoleBundle\Repository\Order; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
{ | { | ||||
protected bool $isJoinProduct = false; | protected bool $isJoinProduct = false; | ||||
protected bool $isJoinSection = false; | |||||
protected bool $isJoinProductFamily = false; | protected bool $isJoinProductFamily = false; | ||||
protected bool $isJoinOrderShop = false; | protected bool $isJoinOrderShop = false; | ||||
protected bool $isJoinOrderStatus = false; | protected bool $isJoinOrderStatus = false; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function joinSection(): self | |||||
{ | |||||
if (!$this->isJoinSection) { | |||||
$this->isJoinSection = true; | |||||
return $this | |||||
->leftJoin('orderShop.section', 'section'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinOrderStatus(): self | public function joinOrderStatus(): self | ||||
{ | { | ||||
$this->joinOrderShop(); | $this->joinOrderShop(); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function filterByMerchant(MerchantInterface $merchant){ | |||||
$this->joinOrderShop(); | |||||
$this->joinSection(); | |||||
return $this->andWhere('section.merchant = :merchant') | |||||
->setParameter('merchant', $merchant); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
class ProductRepositoryQuery extends AbstractRepositoryQuery | class ProductRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
protected bool $isJoinProductFamily =false; | protected bool $isJoinProductFamily =false; | ||||
protected bool $isJoinSections =false; | |||||
protected bool $isJoinProductFamilySectionProperties =false; | protected bool $isJoinProductFamilySectionProperties =false; | ||||
public function __construct(ProductRepository $repository, PaginatorInterface $paginator) | public function __construct(ProductRepository $repository, PaginatorInterface $paginator) | ||||
return $this; | return $this; | ||||
} | } | ||||
public function filterByMerchantViaSection(MerchantInterface $merchant) | |||||
{ | |||||
$this->joinProductFamilySectionProperties(false); | |||||
$this->joinSections(false); | |||||
$this->andWhereMerchant('section', $merchant); | |||||
$this->andWhere('productFamilySectionProperties.status = 1'); | |||||
} | |||||
public function joinSections(bool $addSelect = true): self | |||||
{ | |||||
if (!$this->isJoinSections) { | |||||
$this->isJoinSections = true; | |||||
$this->leftJoin('productFamilySectionProperties.section', 'section'); | |||||
if ($addSelect) { | |||||
$this->addSelect('section'); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinProductFamilySectionProperties(bool $addSelect = true): self | public function joinProductFamilySectionProperties(bool $addSelect = true): self | ||||
{ | { | ||||
$this->joinProductFamily(); | $this->joinProductFamily(); | ||||
$this->leftJoin('productFamily.productFamilySectionProperties', 'productFamilySectionProperties'); | $this->leftJoin('productFamily.productFamilySectionProperties', 'productFamilySectionProperties'); | ||||
if ($addSelect) { | if ($addSelect) { | ||||
$this->addSelect('productFamilySectionProperties'); | |||||
//NB : Ici le select est en commentaire car si il est actif doctrine n'hydrate pas correectement ProductFamilySectionProperties (si filtre sur section les ProductFamilySectionProperties des autres sections ne sont pas chargé et ça peut être problématique pr la gestion des stocks) | |||||
//$this->addSelect('productFamilySectionProperties'); | |||||
} | } | ||||
} | } | ||||
return $this; | return $this; |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use App\Solver\Product\ProductFamilySectionPropertySolver; | use App\Solver\Product\ProductFamilySectionPropertySolver; | ||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\CaracoleBundle\Repository\AbstractStore; | use Lc\CaracoleBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
class ProductStore extends AbstractStore | class ProductStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | use SectionStoreTrait; | ||||
use MerchantStoreTrait; | |||||
protected ProductRepositoryQuery $query; | protected ProductRepositoryQuery $query; | ||||
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver; | protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver; | ||||
public function filtersDefault($query):RepositoryQueryInterface | public function filtersDefault($query):RepositoryQueryInterface | ||||
{ | { | ||||
$this->addFilterBySectionOptionnal($query); | $this->addFilterBySectionOptionnal($query); | ||||
$this->addFilterByMerchantViaSectionOptionnal($query); | |||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
return $query; | return $query; | ||||
//findProductByAvailabilitiesNegative | //findProductByAvailabilitiesNegative | ||||
public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array | public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array | ||||
{ | { | ||||
$query = $this->createQuery($query); | |||||
$query->joinProductFamily(); | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->filterIsOnline(); | $query->filterIsOnline(); | ||||
$query->filterAvailableQuantityNegative(); | $query->filterAvailableQuantityNegative(); | ||||
$query->groupBy('productFamily.id'); | $query->groupBy('productFamily.id'); | ||||
public function getByAvailabilitiesSupplierNegative(ProductRepositoryQuery $query = null): array | public function getByAvailabilitiesSupplierNegative(ProductRepositoryQuery $query = null): array | ||||
{ | { | ||||
$query = $this->createQuery($query); | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->joinProductFamily(); | $query->joinProductFamily(); | ||||
$query->filterIsOnline(); | $query->filterIsOnline(); | ||||
$query->filterAvailableQuantitySupplierNegative(); | $query->filterAvailableQuantitySupplierNegative(); |
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$this->addFilterBySectionOptionnal($query); | $this->addFilterBySectionOptionnal($query); | ||||
$this->addFilterByMerchantOptionnal($query); | |||||
return $query; | return $query; | ||||
} | } | ||||