Skip to content

Render the price filter on the taxon listing again - #300

Merged
Wojdylak merged 1 commit into
BitBagCommerce:masterfrom
Wojdylak:fix/taxon-price-filter-control
Oct 16, 2026
Merged

Wojdylak merged 1 commit into
BitBagCommerce:masterfrom
Wojdylak:fix/taxon-price-filter-control

Conversation

@Wojdylak

Copy link
Copy Markdown
Member

The bug

On the taxon listing the price filter is unreachable. Adding ?price[min_price]=25&price[max_price]=35 to the URL
narrows the results correctly, but the shop renders no control for it.

ShopProductsFilterType builds the field:

$builder
    ->add($this->namePropertyPrefix, NameFilterType::class)
    ->add('price', PriceFilterType::class, ['required' => false, 'label' => false])
    ->setMethod('GET');

templates/Shop/TaxonProductsSearch/content/body/sidebar/facets.html.twig renders form.facets only, and closes the
form with render_rest: false, which hides the leftover fields instead of drawing them. price is not a facet — facets
come from the aggregations of the registered facets, price is a plain child of the form — so the loop never reaches it.

In 1.x the same sidebar rendered it explicitly, next to the options and the attributes:

<div class="item">{{ form_row(form.price) }}</div>
<div class="item"><button type="submit">… Filter</button></div>

The 2.0 rewrite of the view replaced the submit button with the auto-submitting checkboxes and lost the price row along
with it. doc/functionalities.md still promises the control: "here user can also filter the results by the minimum and
maximum price"
.

The fix

The price row is rendered again, in its own container:

{% if form.price is defined %}
    <div class="bitbag-sylius-elasticsearch-plugin-price-filter">
        {{ form_row(form.price) }}
    </div>
{% endif %}

There is no submit button in the form any more, so ElasticSearchCheckboxChangeSubmit watches the container too:

  • the focus leaving the container while the values changed submits the form,
  • Enter inside the container submits it,
  • moving between the min and the max field keeps the focus inside the container, so filling both sends one request.

The checkbox behaviour is untouched, and the class keeps its name so nothing importing it breaks.

Tested

Against a Sylius 2.2 shop with this plugin:

Result
taxon listing sidebar renders Min price and Max price under the attribute facets
submitting 20 – 50 ?price[min_price]=20&price[max_price]=50, 9 products narrowed to the 2 in range, both fields keep their values

The submit behaviour was exercised in a browser against the built class: leaving the container untouched submits nothing,
moving from min to max submits nothing, leaving the container after editing submits once, Enter submits, and a checkbox
still submits as before.

The sidebar of the taxon listing renders the facets of the filter form and closes it with `render_rest: false`, so the
`price` child of `ShopProductsFilterType` — the min and max inputs that `HasPriceBetweenQueryBuilder` reads — never
reaches the page. The filter itself works: `?price[min_price]=25&price[max_price]=35` narrows the results, and the
documentation promises the control ("here user can also filter the results by the minimum and maximum price"), but there
is no way to reach it from the shop. In 1.x the same sidebar rendered `form_row(form.price)` next to the options and the
attributes.

The row is rendered again, in its own container. Since the facets submit themselves on change and the form has no submit
button, `ElasticSearchCheckboxChangeSubmit` now watches the price container as well: it submits when the focus leaves the
container and the values changed, or when Enter is pressed inside it. Moving between the min and the max field keeps the
focus inside the container, so filling both fields sends one request, not two.
@Wojdylak
Wojdylak merged commit 25e9735 into BitBagCommerce:master Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants