Browse Source

Correctif mineur

packProduct
Fabien Normand 3 years ago
parent
commit
b6632f7876
5 changed files with 56 additions and 5 deletions
  1. +1
    -1
      Controller/User/UserAdminController.php
  2. +20
    -0
      Repository/Order/OrderProductRepositoryQuery.php
  3. +28
    -1
      Repository/Product/ProductRepositoryQuery.php
  4. +6
    -3
      Repository/Product/ProductStore.php
  5. +1
    -0
      Repository/Ticket/TicketStore.php

+ 1
- 1
Controller/User/UserAdminController.php View File

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);
} }

+ 20
- 0
Repository/Order/OrderProductRepositoryQuery.php View File

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);
}
} }

+ 28
- 1
Repository/Product/ProductRepositoryQuery.php View File

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;

+ 6
- 3
Repository/Product/ProductStore.php View File

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

+ 1
- 0
Repository/Ticket/TicketStore.php View File

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;
} }



Loading…
Cancel
Save