Skip to content

feat: Add product count fetch for filter buttons#95

Open
ahuininga-orisha wants to merge 2 commits into
developfrom
feat/filter-count
Open

feat: Add product count fetch for filter buttons#95
ahuininga-orisha wants to merge 2 commits into
developfrom
feat/filter-count

Conversation

@ahuininga-orisha

Copy link
Copy Markdown
Collaborator

Summary

  • Mirrors the filter count feature from EmicoEcommerce/Magento2Tweakwise#372 for the Hyvä compatibility layer.
  • On initial page load, the "Show X items" button now displays the actual product count for the current category/search context instead of the generic "Show items" label.
  • On every filter checkbox change (when formFilters is enabled), a lightweight AJAX request is fired to tweakwise/ajax/productcount and all "Show X items" buttons are updated without triggering a full navigation reload.
  • When AJAX filters are enabled and a navigation response is returned, the button count is also updated from the product_count field included in the response (added in #372).
  • In-flight count requests are aborted when a new filter change fires, preventing stale count updates.

How to test

Setup

  1. Enable both tweakwise/layered/enabled and tweakwise/layered/form_filters in Stores → Configuration → Tweakwise.
  2. Make sure the branch from EmicoEcommerce/Magento2Tweakwise#372 is active in vendor/tweakwise/magento2-tweakwise.
  3. Navigate to a category page with Tweakwise facets, e.g. /women/tops-women/.

Scenario 1 — Initial page load

  1. Open the category page.
  2. Each "Show X items" button should display the actual product count for that category, not the generic "Show items" label.

Scenario 2 — Single filter checkbox

  1. Check one filter value (e.g. size M).
  2. Without clicking the button, observe all "Show X items" buttons update to reflect the new count.
  3. Verify the count matches what Tweakwise returns for that category + filter combination.

Scenario 3 — Multiple filters combined

  1. Check a second filter value (e.g. color Gray) while size M is still checked.
  2. All buttons should update to the combined count (category + size M + color Gray).
  3. Uncheck one filter; buttons should update back to the count for the remaining filter only.

Scenario 4 — Full filter apply still works

  1. Check a filter and click the "Show X items" button.
  2. The page should navigate/reload with the filter applied as before.

Scenario 5 — formFilters disabled

  1. Disable tweakwise/layered/form_filters.
  2. Verify no count AJAX requests are fired on filter changes (the feature is inactive).

Comment thread src/view/frontend/templates/layer/view.phtml Outdated
Comment thread src/view/frontend/templates/layer/view.phtml Outdated
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