Skip to content

Commit

Permalink
Merge pull request #253 from BitBagCommerce/use_parameter_for_max_filter
Browse files Browse the repository at this point in the history
add parameter for max option and attribute in filter field
  • Loading branch information
leszczuu authored Sep 23, 2024
2 parents 4bfbe36 + dd061bc commit c44b376
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Finder/ProductAttributesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
5 changes: 3 additions & 2 deletions src/Finder/ProductOptionsFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}

Expand All @@ -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);
}
}
2 changes: 2 additions & 0 deletions src/Resources/config/services/finder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
<argument type="service" id="fos_elastica.finder.bitbag_option_taxons" />
<argument type="service" id="bitbag_sylius_elasticsearch_plugin.query_builder.product_options_by_taxon" />
<argument>%bitbag_es_shop_option_taxons_property%</argument>
<argument>%bitbag_es_filter_options_max%</argument>
</service>

<service id="bitbag_sylius_elasticsearch_plugin.finder.product_attributes" class="BitBag\SyliusElasticsearchPlugin\Finder\ProductAttributesFinder">
<argument type="service" id="fos_elastica.finder.bitbag_attribute_taxons" />
<argument type="service" id="bitbag_sylius_elasticsearch_plugin.query_builder.product_attributes_by_taxon" />
<argument>%bitbag_es_shop_attribute_taxons_property%</argument>
<argument>%bitbag_es_filter_attributes_max%</argument>
</service>
</services>
</container>
2 changes: 2 additions & 0 deletions src/Resources/config/services/property_builder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<parameters>
<parameter key="bitbag_es_excluded_filter_options" type="collection" />
<parameter key="bitbag_es_excluded_filter_attributes" type="collection" />
<parameter key="bitbag_es_filter_attributes_max">20</parameter>
<parameter key="bitbag_es_filter_options_max">20</parameter>
</parameters>

<services>
Expand Down

0 comments on commit c44b376

Please sign in to comment.