Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the amount of terms shown in attributes page #33962

Merged
merged 2 commits into from Jul 25, 2022

Conversation

Konamiman
Copy link
Contributor

@Konamiman Konamiman commented Jul 18, 2022

All Submissions:

Changes proposed in this Pull Request:

As mentioned in #26539 (comment), the product attributes page lists all the existing product attributes together with all the existing terms for each one. In order to improve the performance of that page, the number of terms shown for each attribute is now limited to 100 by default, but this value can be customized by using the newly introduced woocommerce_max_terms_displayed_in_attributes_page filter.

Additionally, the get_terms( $taxonomy) call is changed into get_terms(['taxonomy' => $taxonomy, 'fields' => 'names']) so that only term names are retrieved instead of the full set of terms information.

The UI is adjusted accordingly as well. This is how it looks like when the filter returns 3:

image

And this is with the filter returning zero:

image

How to test the changes in this Pull Request:

  1. Add the following snippet: add_filter('woocommerce_max_terms_displayed_in_attributes_page', function() {return 3;});
  2. Create attributes with 0, 1, 2, 3, 4 and 10 terms, and verify that the attributes list displays as in the first screenshot above.
  3. Change the filter to return zero, and verify that the attributes list displays as in the second screenshot above.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you created a changelog file for each project being changed, ie pnpm changelog add --filter=<project>?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 18, 2022
…page

The attributes page displays all the terms for all the existing
product attributes, which causes a performance problem in sites
with a lot of attributes and terms.

This commit limits the number of attributes shown to 100 by default,
but it also introduces a woocommerce_max_terms_displayed_in_attributes_page
filter to customize it.
@Konamiman Konamiman force-pushed the reduce-terms-shown-in-attributes-page branch from 3240004 to 00b99de Compare July 18, 2022 15:03
@Konamiman Konamiman marked this pull request as ready for review July 18, 2022 15:04
@Konamiman Konamiman self-assigned this Jul 18, 2022
@Konamiman Konamiman requested review from a team and barryhughes and removed request for a team July 18, 2022 15:04
@github-actions
Copy link
Contributor

github-actions bot commented Jul 18, 2022

Test Results Summary

Commit SHA: f042e28

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests11500201170m 41s
E2E Tests185001018614m 4s
To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@Konamiman Konamiman requested review from vedanshujain and removed request for barryhughes July 20, 2022 08:51
Copy link
Contributor

@vedanshujain vedanshujain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think you need to rebase from trunk to get tests to pass.

@Konamiman Konamiman merged commit 0b6de76 into trunk Jul 25, 2022
@Konamiman Konamiman deleted the reduce-terms-shown-in-attributes-page branch July 25, 2022 06:55
@github-actions github-actions bot added this to the 6.9.0 milestone Jul 25, 2022
@github-actions
Copy link
Contributor

Hi @Konamiman, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the release: add testing instructions label

jacob-sewell pushed a commit that referenced this pull request Jul 29, 2022
The attributes page displays all the terms for all the existing
product attributes, which causes a performance problem in sites
with a lot of attributes and terms.

This commit limits the number of attributes shown to 100 by default,
but it also introduces a woocommerce_max_terms_displayed_in_attributes_page
filter to customize it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants