-
Notifications
You must be signed in to change notification settings - Fork 219
Filter data count mismatch > Create the get_attribute_and_meta_counts method #8599
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: -81 B (0%) Total Size: 1.1 MB
ℹ️ View Unchanged
|
…ault list with all terms (with count equal zero) is returned instead.
… filter attributes and the condition query for 'and'
… rely on the new get_attribute_and_meta_counts method instead.
…tical attributes, they are counted once.
…n the macro query if they are not empty.
… new get_product_by_filtered_terms method.
… the min_price and max_price format on get_product_by_metas.
… one of the filtered terms and update the macro query to include those term ids on the WHERE clause.
…API request to correctly fetch the attribute count data.
Excellent! Thanks for the suggestions regarding caching and spotting the glitch when more than one product meta was selected: it's great to have this out of the way sooner than later. #8984 was created to address the PHP Unit tests: Both PRs will be merged once the tests are approved and I also get a second review on this one. |
Bumping to 10.1.0 milestone after p1681128984753939/1681128388.500929-slack-C02UBB1EPEF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this, I tested with different combinations of filters and it is working as expected. Great job! 🚀
02e77fe
to
42e7b9c
Compare
I know it's been merged, but while testing the 10.1.0 I was wondering if changing counters are expected:
In my opinion, it would be better to keep the counts unchanged because as a user I feel like I'm getting lost in what the number actually represents. Quite easily we can make the same filter show multiple numbers:
|
Hi @kmanijak - here is actually the more detailed public discussion on this topic https://github.com/woocommerce/woocommerce-blocks/discussions/9023 |
I'm still struggling updating to the recent WC version since this change broke the collection-data API endpoint mentioned here woocommerce/woocommerce#42157. Could someone please give me some guidance how I can get a subset of products based on a category and use the filters? Thanks! |
@nefeline @roykho do we have any news on this? This PR introduced a breaking change that invalidates the following:
|
In this PR, the new
get_attribute_and_meta_counts
method is introduced, which is responsible for fetching the counts for the Filter by Attribute block.🎯 #8563
These queries were tailor-made to handle all combinations of filters natively supported by WooCommerce blocks, including:
With that said, the following use-case scenarios were taken into consideration during the development and tests phase:
1. A single Filter by Attribute block used alongside the Products (Beta) block with condition = any (
or
)Screen.Recording.2023-03-31.at.12.47.39.mov
2. A single Filter by Attribute block used alongside the Products (Beta) block with condition = all (
and
)Screen.Recording.2023-03-31.at.12.53.20.mov
3. Two or more Filter by Attribute blocks used alongside the Products (Beta) block
Screen.Recording.2023-03-31.at.12.43.34.mov
4. Filter by Attribute block used alongside the Filter by stock status and Products (Beta) blocks.
Screen.Recording.2023-03-31.at.12.39.38.mov
5. Filter by Attribute block used alongside the Filter by rating and Products (Beta) blocks.
Screen.Recording.2023-03-31.at.12.36.39.mov
6. Filter by Attribute block used alongside the Filter by price and Products (Beta) blocks.
Screen.Recording.2023-03-31.at.12.32.26.mov
7. Filter by Attribute block used alongside the Filter by stock status, Filter by price, Filter by rating, and Products (Beta) blocks.
Screen.Recording.2023-03-31.at.12.22.11.mov
Discussion points
Should we update the counts when filtering attributes with the condition = any (
or
)? Currently, the counts are updated to match the filtered product results. Alternatively, we could keep the counts unchanged.Should we hide products with the count = zero when the condition is all (
and
)? Currently, the filtered products with counts equal to zero are intentionally hidden. Alternatively, we could keep them on the list independently of the results.Any preferences/thoughts?
Note regarding PHP unit tests
I'm opening a separate PR for updating & fixing those.
Other Checks
Testing
Automated Tests
User Facing Testing
WooCommerce Visibility
Changelog