Skip to content

Commit dd061bc

Browse files
jbcrleszczuu
authored andcommitted
add parameter for max option and attribute in filter field
1 parent 247cea9 commit dd061bc

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/Finder/ProductAttributesFinder.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ final class ProductAttributesFinder implements ProductAttributesFinderInterface
2222
public function __construct(
2323
private FinderInterface $attributesFinder,
2424
private QueryBuilderInterface $attributesByTaxonQueryBuilder,
25-
private string $taxonsProperty
26-
) {
25+
private string $taxonsProperty,
26+
private int $filterMax = 20,
27+
) {
2728
}
2829

2930
public function findByTaxon(TaxonInterface $taxon): ?array
@@ -34,6 +35,6 @@ public function findByTaxon(TaxonInterface $taxon): ?array
3435
/** @var AbstractQuery $query */
3536
$query = $this->attributesByTaxonQueryBuilder->buildQuery($data);
3637

37-
return $this->attributesFinder->find($query, 20);
38+
return $this->attributesFinder->find($query, $this->filterMax);
3839
}
3940
}

src/Finder/ProductOptionsFinder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ final class ProductOptionsFinder implements ProductOptionsFinderInterface
2222
public function __construct(
2323
private FinderInterface $optionsFinder,
2424
private QueryBuilderInterface $productOptionsByTaxonQueryBuilder,
25-
private string $taxonsProperty
25+
private string $taxonsProperty,
26+
private int $filterMax = 20
2627
) {
2728
}
2829

@@ -34,6 +35,6 @@ public function findByTaxon(TaxonInterface $taxon): ?array
3435
/** @var AbstractQuery $query */
3536
$query = $this->productOptionsByTaxonQueryBuilder->buildQuery($data);
3637

37-
return $this->optionsFinder->find($query, 20);
38+
return $this->optionsFinder->find($query, $this->filterMax);
3839
}
3940
}

src/Resources/config/services/finder.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
<argument type="service" id="fos_elastica.finder.bitbag_option_taxons" />
2424
<argument type="service" id="bitbag_sylius_elasticsearch_plugin.query_builder.product_options_by_taxon" />
2525
<argument>%bitbag_es_shop_option_taxons_property%</argument>
26+
<argument>%bitbag_es_filter_options_max%</argument>
2627
</service>
2728

2829
<service id="bitbag_sylius_elasticsearch_plugin.finder.product_attributes" class="BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinder">
2930
<argument type="service" id="fos_elastica.finder.bitbag_attribute_taxons" />
3031
<argument type="service" id="bitbag_sylius_elasticsearch_plugin.query_builder.product_attributes_by_taxon" />
3132
<argument>%bitbag_es_shop_attribute_taxons_property%</argument>
33+
<argument>%bitbag_es_filter_attributes_max%</argument>
3234
</service>
3335
</services>
3436
</container>

src/Resources/config/services/property_builder.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<parameters>
55
<parameter key="bitbag_es_excluded_filter_options" type="collection" />
66
<parameter key="bitbag_es_excluded_filter_attributes" type="collection" />
7+
<parameter key="bitbag_es_filter_attributes_max">20</parameter>
8+
<parameter key="bitbag_es_filter_options_max">20</parameter>
79
</parameters>
810

911
<services>

0 commit comments

Comments
 (0)