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

Compatibility with WooCommerce HPOS #3476

Open
1 task done
felipeelia opened this issue May 31, 2023 · 5 comments · May be fixed by #4038
Open
1 task done

Compatibility with WooCommerce HPOS #3476

felipeelia opened this issue May 31, 2023 · 5 comments · May be fixed by #4038
Assignees
Labels
enhancement large (16 - 40 hours)
Milestone

Comments

@felipeelia
Copy link
Member

felipeelia commented May 31, 2023

Is your enhancement related to a problem? Please describe.

This issue is to investigate ElasticPress's compatibility with WooCommerce High-Performance Order Storage.

My findings so far:

  • 100% compatibility would be very hard to achieve, as data requests to the new custom table are spread throughout the code base, like here, for example;
  • It seems the best candidate for a replacement with a compatibility layer would be the OrdersTableQuery class, as it is responsible for running queries
  • The OrdersTableQuery class is called directly by the OrdersTableDataStore class here, so we might need to override that one too.
  • Due to the way the WC container works, it won't allow us to simply replace a class, so we might need a new filter to be added.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@felipeelia felipeelia added this to the 5.0.0 milestone May 31, 2023
@vedanshujain
Copy link

Hey @felipeelia , from WC team here. I would love to help you with HPOS compatibility for ElasticPress. It looks like currently you hook into posts_pre_query to hijack WP query and populate results from elasticsearch, would be happy to add similar filter for HPOS as well. It seems we won't need to create new index for HPOS orders, since there is already a allowlist for what data can be synced, and we can add HPOS orders in the same index (note that we always insert a shop_order_placehold post and use the same ID in order tables, so a ID conflict won't happen).

Let us know if there is anything else you would need besides an equivalent posts_pre_query filter.

@felipeelia
Copy link
Member Author

@vedanshujain you got it right. It is worth saying though that an equivalent filter for posts_pre_query would be a good start, but we will probably need some further changes, especially given the number of times the code seems to be touching the database directly.

@vedanshujain
Copy link

Cool cool, we will get a PR started for posts_pre_query. Please let us know what you discover during development, we would be happy to add more action/filters where they makes sense, and especially if a similar filter already exists with the posts.

@vedanshujain
Copy link

@felipeelia , I can try and give it a shot for a draft PR, if this is still on the roadmap?

@felipeelia
Copy link
Member Author

To have this one done, in general steps, we need to:

  1. Create a new file called OrdersHPOS.php in includes/classes/Feature/WooCommerce/
  2. Conditionally call it from includes/classes/Feature/WooCommerce/Orders.php
  3. Make Orders be indexed in ElasticPress posts' index
  4. Use the woocommerce_hpos_pre_query filter to prevent any SQL query from being fired and use ElasticPress instead.

@felipeelia felipeelia self-assigned this Aug 13, 2024
@felipeelia felipeelia added the large (16 - 40 hours) label Aug 20, 2024
@felipeelia felipeelia linked a pull request Dec 10, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement large (16 - 40 hours)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants