Browse Source

[Frontend] Rayons : cache http

develop
Guillaume Bourgeois 2 years ago
parent
commit
09e767fa26
4 changed files with 23 additions and 10 deletions
  1. +1
    -1
      Repository/Product/ProductFamilyRepositoryQuery.php
  2. +9
    -7
      Resolver/ProductFamilyResolver.php
  3. +11
    -1
      Solver/Order/OrderShopSolver.php
  4. +2
    -1
      Solver/Product/ProductFamilySectionPropertySolver.php

+ 1
- 1
Repository/Product/ProductFamilyRepositoryQuery.php View File

$this->innerJoin('.products', 'products'); $this->innerJoin('.products', 'products');
if ($addSelect) { if ($addSelect) {
// Décommenté sinon doctrine n'hydrate pas correctement les produits liés au ProductFamily (exemple : un seul sur deux) // Décommenté sinon doctrine n'hydrate pas correctement les produits liés au ProductFamily (exemple : un seul sur deux)
// $this->addSelect('products');
//$this->addSelect('products');
} }
} }
return $this; return $this;

+ 9
- 7
Resolver/ProductFamilyResolver.php View File

} }
} }


public function getCheapestProduct(ProductFamilyInterface $productFamily, OrderShopInterface $orderShop)
public function getCheapestProduct(ProductFamilyInterface $productFamily, OrderShopInterface $orderShop = null)
{ {
$priceSolver = $this->priceSolver; $priceSolver = $this->priceSolver;


); );
} }


public function getCheapestProductByRefUnit(ProductFamilyInterface $productFamily, OrderShopInterface $orderShop)
public function getCheapestProductByRefUnit(ProductFamilyInterface $productFamily, OrderShopInterface $orderShop = null)
{ {
$priceSolver = $this->priceSolver; $priceSolver = $this->priceSolver;


); );
} }


public function getMostExpensiveProductByRefUnit(ProductFamilyInterface $productFamily, OrderShopInterface $orderShop)
public function getMostExpensiveProductByRefUnit(ProductFamilyInterface $productFamily, OrderShopInterface $orderShop = null)
{ {
$priceSolver = $this->priceSolver; $priceSolver = $this->priceSolver;


ProductFamilyInterface $productFamily, ProductFamilyInterface $productFamily,
$comparisonFunction, $comparisonFunction,
$returnSelfIfNotActiveProducts, $returnSelfIfNotActiveProducts,
OrderShopInterface $orderShop
OrderShopInterface $orderShop = null
) )
{ {
if ($productFamily->getActiveProducts()) { if ($productFamily->getActiveProducts()) {
if (count($products) > 0) { if (count($products) > 0) {
usort($products, $comparisonFunction); usort($products, $comparisonFunction);


foreach ($products as $product) {
if ($this->orderShopSolver->isProductAvailable($orderShop->getSection(), $orderShop, $product, 1, true)) {
return $product;
if($orderShop) {
foreach ($products as $product) {
if ($this->orderShopSolver->isProductAvailable($orderShop->getSection(), $orderShop, $product, 1, true)) {
return $product;
}
} }
} }



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

// isProductAvailable // isProductAvailable
public function isProductAvailable( public function isProductAvailable(
SectionInterface $section, SectionInterface $section,
OrderShopInterface $orderShop,
?OrderShopInterface $orderShop,
ProductInterface $product, ProductInterface $product,
int $quantityOrder = 0, int $quantityOrder = 0,
bool $checkCart = false bool $checkCart = false
} }
} }


public function isOneProductAvailable(SectionInterface $section, $productArray): bool
{
foreach($productArray as $product) {
if($this->isProductAvailable($section, null, $product, 1, false)) {
return true;
}
}
return false;
}

public function isOneProductAvailableAddCart(OrderShopInterface $orderShop, $products): bool public function isOneProductAvailableAddCart(OrderShopInterface $orderShop, $products): bool
{ {
foreach ($products as $product) { foreach ($products as $product) {

+ 2
- 1
Solver/Product/ProductFamilySectionPropertySolver.php View File

public function getProductFamilySectionProperty(ProductFamilyInterface $productFamily, SectionInterface $section):? ProductFamilySectionPropertyInterface public function getProductFamilySectionProperty(ProductFamilyInterface $productFamily, SectionInterface $section):? ProductFamilySectionPropertyInterface
{ {
foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) { foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {
if ($productFamilySectionProperty->getSection() === $section) {
if ($productFamilySectionProperty->getSection()->getId() == $section->getId()) {
return $productFamilySectionProperty; return $productFamilySectionProperty;
} }
} }

return null; return null;
} }



Loading…
Cancel
Save