浏览代码

Correctif mineur

packProduct
Fabien Normand 2 年前
父节点
当前提交
b6632f7876
共有 5 个文件被更改,包括 56 次插入5 次删除
  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 查看文件

@@ -31,7 +31,7 @@ abstract class UserAdminController extends SovUserAdminController
foreach ($entity->getActions() as $action){
if($action->getName() == ActionDefinition::SWITCH_USER){
$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()));
$action->setLinkUrl($url);
}

+ 20
- 0
Repository/Order/OrderProductRepositoryQuery.php 查看文件

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
@@ -14,6 +15,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
{

protected bool $isJoinProduct = false;
protected bool $isJoinSection = false;
protected bool $isJoinProductFamily = false;
protected bool $isJoinOrderShop = false;
protected bool $isJoinOrderStatus = false;
@@ -103,6 +105,17 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

public function joinSection(): self
{
if (!$this->isJoinSection) {
$this->isJoinSection = true;

return $this
->leftJoin('orderShop.section', 'section');
}
return $this;
}

public function joinOrderStatus(): self
{
$this->joinOrderShop();
@@ -114,4 +127,11 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
}
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 查看文件

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Product;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
@@ -12,6 +13,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;
class ProductRepositoryQuery extends AbstractRepositoryQuery
{
protected bool $isJoinProductFamily =false;
protected bool $isJoinSections =false;
protected bool $isJoinProductFamilySectionProperties =false;

public function __construct(ProductRepository $repository, PaginatorInterface $paginator)
@@ -43,6 +45,29 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery

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
{
$this->joinProductFamily();
@@ -52,7 +77,9 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery

$this->leftJoin('productFamily.productFamilySectionProperties', 'productFamilySectionProperties');
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;

+ 6
- 3
Repository/Product/ProductStore.php 查看文件

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Product;

use App\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
@@ -10,6 +11,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;
class ProductStore extends AbstractStore
{
use SectionStoreTrait;
use MerchantStoreTrait;

protected ProductRepositoryQuery $query;
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;
@@ -28,6 +30,7 @@ class ProductStore extends AbstractStore
public function filtersDefault($query):RepositoryQueryInterface
{
$this->addFilterBySectionOptionnal($query);
$this->addFilterByMerchantViaSectionOptionnal($query);
$query->filterIsOnlineAndOffline();

return $query;
@@ -41,8 +44,8 @@ class ProductStore extends AbstractStore
//findProductByAvailabilitiesNegative
public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array
{
$query = $this->createQuery($query);
$query->joinProductFamily();
$query = $this->createDefaultQuery($query);
$query->filterIsOnline();
$query->filterAvailableQuantityNegative();
$query->groupBy('productFamily.id');
@@ -58,7 +61,7 @@ class ProductStore extends AbstractStore

public function getByAvailabilitiesSupplierNegative(ProductRepositoryQuery $query = null): array
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);
$query->joinProductFamily();
$query->filterIsOnline();
$query->filterAvailableQuantitySupplierNegative();

+ 1
- 0
Repository/Ticket/TicketStore.php 查看文件

@@ -17,6 +17,7 @@ class TicketStore extends SovTicketStore
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$this->addFilterBySectionOptionnal($query);
$this->addFilterByMerchantOptionnal($query);
return $query;
}


正在加载...
取消
保存