Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Product Query - add support for the global query #7382

Merged
merged 63 commits into from
Nov 28, 2022

Conversation

gigitux
Copy link
Contributor

@gigitux gigitux commented Oct 12, 2022

This PR is blocked by #7257.

This PR adds:

  • an option equivalent to “Inherit Query from Template” (perhaps even visually identical) to make the Product Query compatible with FSE templates. ⚠️ Please, don't review the UI and the label. We can iterate them easily in the next weeks.
  • Merge global query into variation query.
  • Merge query parameters from the URL into the global query to allow compatibility with filters.

Fixes #6863

Other Checks

  • This PR adds/removes a feature flag & I've updated this doc.
  • This PR adds/removes an experimental interfaces and I've updated this doc.
  • I tagged two reviewers because this PR makes queries to the database or I think it might have some security impact.

Screenshots

image

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

User Facing Testing

Product Search Template

  1. Edit the Product Search template.
  2. In the header section, add the Product Search block.
  3. Replace the PHP classic block with the Product Query block.
  4. Set the woo inherit query from template setting to true.
  5. Save. Go on the front end.
  6. With the Product Search block, search a product and be sure that the results that the Product Query renders are correct.
  7. Edit the Product Search template.
  8. Add filter blocks or/and enable the on-sale setting. Go on the front end.
  9. With the Product Search block, search a product and add some filters and be sure that the results that the Product Query renders are correct.

Products By Category Template

  1. Edit the Products by Category template.
  2. Replace the PHP classic block with the Product Query block.
  3. Set the woo inherit query from template setting to true.
  4. Save. Go on the front end.
  5. Go to this URL product-category/clothing/tshirts/. In this way, the Product by Category will be rendered and should be rendered only products that are in the T-shirts category.
  6. Edit the Products By Category template.
  7. Add filter blocks or/and enable the on-sale setting. Go on the front end.
  8. Go to this URL product-category/clothing/tshirts/. In this way, the Product by Category will be rendered and should be rendered only products that are in the T-shirts category and match the filters/variation.

Products By Tag Template

  1. Edit the Products by Tag template.
  2. Replace the PHP classic block with the Product Query block.
  3. Set the woo inherit query from template setting to true.
  4. Create a tag and add some products.
  5. Save. Go on the front end.
  6. Go to this URL /product-tag/${name_tag}/. In this way, the Product by Tag will be rendered and should be rendered only products that are in the selected tag.
  7. Edit the Products By Tag template.
  8. Add filter blocks or/and enable the on-sale setting. Go on the front end.
  9. Go to this URL /product-tag/${name_tag}/. In this way, the Products By Tag template will be rendered and should be rendered only products that are in the selected tag and match the filters/variation.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Product Query - Add support for the Filter By Price Block
Product Query - Add support for the Filter By Attributes block
Product Query - Add support for the Filter By Stock Block
…e variation #7245

fix filter blocks: the data (e.g: max price or stock-status) match the variation
@gigitux gigitux added type: enhancement The issue is a request for an enhancement. skip-changelog PRs that you don't want to appear in the changelog. labels Oct 12, 2022
@github-actions
Copy link
Contributor

This PR has been marked as stale because it has not seen any activity within the past 7 days. Our team uses this tool to help surface pull requests that have slipped through review.

If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label.

@github-actions github-actions bot added the status: stale Stale issues and PRs have had no updates for 60 days. label Nov 23, 2022
@gigitux gigitux removed the status: stale Stale issues and PRs have had no updates for 60 days. label Nov 23, 2022
@gigitux gigitux force-pushed the fix/product-query-global-query branch from e99c466 to dac0895 Compare November 24, 2022 14:14
@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2022

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

@gigitux
Copy link
Contributor Author

gigitux commented Nov 25, 2022

Hey @dinhtungdu,
I updated this PR and I added the feature flag (on both sides, maybe should we do it only on the JS side?)! Also, in this PR I already merged #7697.

Comment on lines 22 to 25
// This is a feature flag to enable the custom inherit Global Query implementation.
// This is not intended to be a permanent feature flag, but rather a temporary.
// https://github.com/woocommerce/woocommerce-blocks/pull/7382
const isCustomInheritGlobalQueryImplementationEnabled = false;
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about using an experimental flag here instead? I think we just need to limit the global query support to experimental/development build only. 🤔

Copy link
Contributor Author

@gigitux gigitux Nov 25, 2022

Choose a reason for hiding this comment

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

I think we just need to limit the global query support to experimental/development build only.

At least for now, we want to show the option inherited query from the template from Gutenberg. The Product Query is a foundation for other blocks, too (for example, Buy it again), and having two inherit query from template options can be confusing for the developers that check the block for the first time.

Also, this is a super WIP code because there is still a discussion about how we should approach the problem: this is why I used this approach.

For me, It is fine to change it, but I think it could not be very clear.

Copy link
Member

Choose a reason for hiding this comment

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

The Product Query is a foundation for other blocks, too (for example, Buy it again), and having two inherit query from template options can be confusing for the developers that check the block for the first time.

Make senses!

Can you explain how can we use this flag for development later? I mean what do we need to do to enable the flag? At glance, we have to temporarily change the flag in the source code, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain how can we use this flag for development later? I mean what do we need to do to enable the flag? At glance, we have to temporarily change the flag in the source code, right?

Yes! Just set isCustomInheritGlobalQueryImplementationEnabled and is_custom_inherit_global_query_implementation_enabled to true.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe adding a note here to update the PHP flag too? (and vice-versa)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense! I updated the comments!

Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation! I left an optional comment but as discussed, this is LGTM so approving!

Comment on lines 22 to 25
// This is a feature flag to enable the custom inherit Global Query implementation.
// This is not intended to be a permanent feature flag, but rather a temporary.
// https://github.com/woocommerce/woocommerce-blocks/pull/7382
const isCustomInheritGlobalQueryImplementationEnabled = false;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe adding a note here to update the PHP flag too? (and vice-versa)

@github-actions github-actions bot added this to the 9.1.0 milestone Nov 28, 2022
@gigitux gigitux merged commit bbee496 into trunk Nov 28, 2022
@gigitux gigitux deleted the fix/product-query-global-query branch November 28, 2022 14:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block-type: product-query Issues related to/affecting all product-query variations. skip-changelog PRs that you don't want to appear in the changelog. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Product Query: custom implementation of inherit query from template
3 participants