Browse Source

Optimisation : essais cache

packProduct
Guillaume 2 years ago
parent
commit
a9013b4b3c
3 changed files with 6 additions and 7 deletions
  1. +1
    -1
      Repository/Product/ProductFamilyRepositoryQuery.php
  2. +1
    -0
      Repository/Product/ProductFamilyStore.php
  3. +4
    -6
      Solver/Product/ProductFamilySolver.php

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

return $this->andWhereEqual('supplier', $supplier); return $this->andWhereEqual('supplier', $supplier);
} }


public function joinProductCategories(bool $addSelect = false): self
public function joinProductCategories(bool $addSelect = true): self
{ {
if (!$this->isJoinProductCategories) { if (!$this->isJoinProductCategories) {
$this->isJoinProductCategories = true; $this->isJoinProductCategories = true;

+ 1
- 0
Repository/Product/ProductFamilyStore.php View File

'ids' => [], 'ids' => [],
'categories' => [], 'categories' => [],
]; ];

foreach ($productFamilies as $productFamily) { foreach ($productFamilies as $productFamily) {
$conditions['ids'][] = $productFamily->getId(); $conditions['ids'][] = $productFamily->getId();
$conditions['categories'] = array_merge( $conditions['categories'] = array_merge(

+ 4
- 6
Solver/Product/ProductFamilySolver.php View File



class ProductFamilySolver class ProductFamilySolver
{ {

protected ProductSolver $productSolver; protected ProductSolver $productSolver;
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver; protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;
protected ProductCategorySolver $productCategorySolver; protected ProductCategorySolver $productCategorySolver;
$this->productCategorySolver = $productCategorySolver; $this->productCategorySolver = $productCategorySolver;
} }



public static function getBehaviorCountStockChoices(): array public static function getBehaviorCountStockChoices(): array
{ {
return [ return [
return $productsOnlineArray; return $productsOnlineArray;
} }



public function getReductionCatalogInherited(ProductFamilyInterface $productFamily): ?ReductionCatalogInterface public function getReductionCatalogInherited(ProductFamilyInterface $productFamily): ?ReductionCatalogInterface
{ {
return $productFamily->getReductionCatalog(); return $productFamily->getReductionCatalog();
} }



public function getProductCategoryParent(ProductFamilyInterface $productFamily, SectionInterface $section) public function getProductCategoryParent(ProductFamilyInterface $productFamily, SectionInterface $section)
{ {
$productCategories = $productFamily->getProductCategories(); $productCategories = $productFamily->getProductCategories();


if (count($productCategories) > 0) { if (count($productCategories) > 0) {

foreach ($productCategories as $productCategory) { foreach ($productCategories as $productCategory) {
if($productCategory->getSection() === $section && $productCategory->getParent()!==null){
if($productCategory->getSection()->getId() == $section->getId()
&& $productCategory->getParent() !== null) {

return $productCategory->getParent(); return $productCategory->getParent();
} }
} }

} }


return false; return false;

Loading…
Cancel
Save