Browse Source

[Frontend] Rayons : cache http

develop
Guillaume Bourgeois 1 year 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

@@ -189,7 +189,7 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
$this->innerJoin('.products', 'products');
if ($addSelect) {
// 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;

+ 9
- 7
Resolver/ProductFamilyResolver.php View File

@@ -43,7 +43,7 @@ class ProductFamilyResolver
}
}

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

@@ -59,7 +59,7 @@ class ProductFamilyResolver
);
}

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

@@ -75,7 +75,7 @@ class ProductFamilyResolver
);
}

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

@@ -95,7 +95,7 @@ class ProductFamilyResolver
ProductFamilyInterface $productFamily,
$comparisonFunction,
$returnSelfIfNotActiveProducts,
OrderShopInterface $orderShop
OrderShopInterface $orderShop = null
)
{
if ($productFamily->getActiveProducts()) {
@@ -104,9 +104,11 @@ class ProductFamilyResolver
if (count($products) > 0) {
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

@@ -126,7 +126,7 @@ class OrderShopSolver
// isProductAvailable
public function isProductAvailable(
SectionInterface $section,
OrderShopInterface $orderShop,
?OrderShopInterface $orderShop,
ProductInterface $product,
int $quantityOrder = 0,
bool $checkCart = false
@@ -171,6 +171,16 @@ class OrderShopSolver
}
}

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
{
foreach ($products as $product) {

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

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

return null;
}


Loading…
Cancel
Save