Browse Source

[Backend] Edition de produit - packProductItem #118

packProduct
Fabien Normand 2 years ago
parent
commit
3f4c3a7e3d
4 changed files with 52 additions and 53 deletions
  1. +48
    -40
      Repository/Product/ProductRepositoryQuery.php
  2. +1
    -1
      Solver/Order/OrderShopSolver.php
  3. +3
    -0
      Solver/Price/ProductPriceSolver.php
  4. +0
    -12
      Solver/Product/ProductSolver.php

+ 48
- 40
Repository/Product/ProductRepositoryQuery.php View File



class ProductRepositoryQuery extends AbstractRepositoryQuery class ProductRepositoryQuery extends AbstractRepositoryQuery
{ {
protected bool $isJoinProductFamily =false;
protected bool $isJoinSections =false;
protected bool $isJoinProductFamilySectionProperties =false;
protected bool $isJoinProductFamily = false;
protected bool $isJoinSections = false;
protected bool $isJoinProductFamilySectionProperties = false;


public function __construct(ProductRepository $repository, PaginatorInterface $paginator) public function __construct(ProductRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'product', $paginator); parent::__construct($repository, 'product', $paginator);
} }

public function orderByDefault(): \Lc\SovBundle\Repository\AbstractRepositoryQuery public function orderByDefault(): \Lc\SovBundle\Repository\AbstractRepositoryQuery
{ {
return $this->orderBy('position', 'ASC'); return $this->orderBy('position', 'ASC');
} }


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


return $this return $this
->innerJoin('.productFamily', 'productFamily')
->addSelect('productFamily');
->innerJoin('.productFamily', 'productFamily')
->addSelect('productFamily');
} }
return $this; return $this;
} }


public function filterBySection(SectionInterface $section):self
public function filterBySection(SectionInterface $section): self
{ {
$this->joinProductFamilySectionProperties(false); $this->joinProductFamilySectionProperties(false);
$this->andWhereSection('productFamilySectionProperties', $section); $this->andWhereSection('productFamilySectionProperties', $section);
} }




public function filterIsOnline():self
public function filterIsOnline(): self
{ {
$this->joinProductFamily(); $this->joinProductFamily();
$this->andWhereStatus('productFamily', 1); $this->andWhereStatus('productFamily', 1);
return $this; return $this;
} }


public function filterIsOnSale(): self
{
$this->joinProductFamily();
$this->andWhere('productFamily.saleStatus = 1');
return $this;
}



public function filterIsOriginProduct():self
public function filterIsOriginProduct(): self
{ {
$this->andWhere('.originProduct = 1'); $this->andWhere('.originProduct = 1');
return $this; return $this;
} }




public function filterIsNotAvailableQuantitySupplierUnlimited():self
public function filterIsNotAvailableQuantitySupplierUnlimited(): self
{ {
$this->andWhere('productFamily.availableQuantitySupplierUnlimited != 1'); $this->andWhere('productFamily.availableQuantitySupplierUnlimited != 1');
return $this; return $this;
} }




public function filterAvailableQuantityNegative() :self
public function filterAvailableQuantityNegative(): self
{ {


$this->andWhere( $this->andWhere(
$this->query->expr()->orX(
$this->query->expr()->andX(
$this->query->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantity < 0 '
),
$this->query->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'product.availableQuantity < 0 '
)
$this->query->expr()->orX(
$this->query->expr()->andX(
$this->query->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantity < 0 '
),
$this->query->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'product.availableQuantity < 0 '
) )
)
); );
$this->setParameter( $this->setParameter(
'behaviorCountStockByProductFamily',
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
'behaviorCountStockByProductFamily',
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
); );
$this->setParameter('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE); $this->setParameter('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); $this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);
return $this; return $this;
} }


public function filterAvailableQuantitySupplierNegative() :self
public function filterAvailableQuantitySupplierNegative(): self
{ {


$this->andWhere( $this->andWhere(
$this->query->expr()->orX(
$this->query->expr()->andX(
$this->query->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantitySupplier < 0 '
),
$this->query->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'product.availableQuantitySupplier < 0 '
)
$this->query->expr()->orX(
$this->query->expr()->andX(
$this->query->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantitySupplier < 0 '
),
$this->query->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'product.availableQuantitySupplier < 0 '
) )
)
); );
$this->setParameter( $this->setParameter(
'behaviorCountStockByProductFamily',
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
'behaviorCountStockByProductFamily',
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
); );
$this->setParameter('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE); $this->setParameter('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); $this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);

+ 1
- 1
Solver/Order/OrderShopSolver.php View File

return false; return false;
} }



$productFamily = $product->getProductFamily(); $productFamily = $product->getProductFamily();
$quantityAsked = $quantityOrder; $quantityAsked = $quantityOrder;


return true; return true;
} }
} }

return false; return false;
} }



+ 3
- 0
Solver/Price/ProductPriceSolver.php View File



public function getPriceWithTaxAndReduction(ProductPropertyInterface $product) public function getPriceWithTaxAndReduction(ProductPropertyInterface $product)
{ {
//TODO voir différence entre prix ici et dans tableau décli
dump('PV HT : '.$this->getPrice($product));
dump('PV TTC : '.$this->getPriceWithTax($product));
return $this->applyReductionCatalog( return $this->applyReductionCatalog(
$product, $product,
$this->getPrice($product), $this->getPrice($product),

+ 0
- 12
Solver/Product/ProductSolver.php View File

} }


$allCategoriesSalesOff = true; $allCategoriesSalesOff = true;
$unavailableSpecificDay = false;


foreach ($product->getProductFamily()->getProductCategories() as $category) { foreach ($product->getProductFamily()->getProductCategories() as $category) {
if ($category->getParent()) { if ($category->getParent()) {
$allCategoriesSalesOff = false; $allCategoriesSalesOff = false;
} }
} }

// specific day
// @TODO : spécifique pdl ?
$displaySpecificDay = $category->getDisplaySpecificDay();
if ($displaySpecificDay && $displaySpecificDay != date('N')) {
$unavailableSpecificDay = true;
}
} }


if ($allCategoriesSalesOff) { if ($allCategoriesSalesOff) {
return false; return false;
} }


if ($unavailableSpecificDay) {
return false;
}

return true; return true;
} }



Loading…
Cancel
Save