From dd061bc7cb5d636e914247d7c1ab02fb12afb3f1 Mon Sep 17 00:00:00 2001
From: jb cr <51637606+jbcr@users.noreply.github.com>
Date: Tue, 19 May 2020 10:14:41 +0200
Subject: [PATCH] add parameter for max option and attribute in filter field
---
src/Finder/ProductAttributesFinder.php | 7 ++++---
src/Finder/ProductOptionsFinder.php | 5 +++--
src/Resources/config/services/finder.xml | 2 ++
src/Resources/config/services/property_builder.xml | 2 ++
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/Finder/ProductAttributesFinder.php b/src/Finder/ProductAttributesFinder.php
index ad2326c9..e188178b 100644
--- a/src/Finder/ProductAttributesFinder.php
+++ b/src/Finder/ProductAttributesFinder.php
@@ -22,8 +22,9 @@ final class ProductAttributesFinder implements ProductAttributesFinderInterface
public function __construct(
private FinderInterface $attributesFinder,
private QueryBuilderInterface $attributesByTaxonQueryBuilder,
- private string $taxonsProperty
- ) {
+ private string $taxonsProperty,
+ private int $filterMax = 20,
+ ) {
}
public function findByTaxon(TaxonInterface $taxon): ?array
@@ -34,6 +35,6 @@ public function findByTaxon(TaxonInterface $taxon): ?array
/** @var AbstractQuery $query */
$query = $this->attributesByTaxonQueryBuilder->buildQuery($data);
- return $this->attributesFinder->find($query, 20);
+ return $this->attributesFinder->find($query, $this->filterMax);
}
}
diff --git a/src/Finder/ProductOptionsFinder.php b/src/Finder/ProductOptionsFinder.php
index 8deee9f1..a16e0d38 100644
--- a/src/Finder/ProductOptionsFinder.php
+++ b/src/Finder/ProductOptionsFinder.php
@@ -22,7 +22,8 @@ final class ProductOptionsFinder implements ProductOptionsFinderInterface
public function __construct(
private FinderInterface $optionsFinder,
private QueryBuilderInterface $productOptionsByTaxonQueryBuilder,
- private string $taxonsProperty
+ private string $taxonsProperty,
+ private int $filterMax = 20
) {
}
@@ -34,6 +35,6 @@ public function findByTaxon(TaxonInterface $taxon): ?array
/** @var AbstractQuery $query */
$query = $this->productOptionsByTaxonQueryBuilder->buildQuery($data);
- return $this->optionsFinder->find($query, 20);
+ return $this->optionsFinder->find($query, $this->filterMax);
}
}
diff --git a/src/Resources/config/services/finder.xml b/src/Resources/config/services/finder.xml
index 445526f5..d63f4738 100644
--- a/src/Resources/config/services/finder.xml
+++ b/src/Resources/config/services/finder.xml
@@ -23,12 +23,14 @@
%bitbag_es_shop_option_taxons_property%
+ %bitbag_es_filter_options_max%
%bitbag_es_shop_attribute_taxons_property%
+ %bitbag_es_filter_attributes_max%
diff --git a/src/Resources/config/services/property_builder.xml b/src/Resources/config/services/property_builder.xml
index 6babd73f..9f25c318 100644
--- a/src/Resources/config/services/property_builder.xml
+++ b/src/Resources/config/services/property_builder.xml
@@ -4,6 +4,8 @@
+ 20
+ 20