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

Allow searches for variation SKU in admin interface #1828

Closed

Conversation

kallehauge
Copy link
Contributor

@kallehauge kallehauge commented Jul 6, 2020

Description of the Change

This is a proof of concept of handling searching by products variations SKU and returning parent product (#781) and is a refactored version of #941 since it got closed due to major code changes in 3.0.

The point of this is to be able to search for a variation sku and then get the parent product in the admin interface (this is a default feature in WooCommerce).

Verification Process

I created a new variable product with a couple of variants. These all have a new __wc_ep_variations_skus meta value in Elasticsearch.
The value of __wc_ep_variations_skus is being updated when the parent product is updating which is the core logic of the PR but the value have also been tested to update when a variation is being deleted through the admin interface without pressing the "Update" button for the parent product and the value have also been tested to update when using the variation Save Changes button below variations in the interface (hence; not the "Update parent post button")

I have also tested that the admin product overview list changes only affect the mentioned list by test other overview lists (like Orders, Pages, Posts) and on the front-end when Elasticsearch is enabled.

Checklist:

  • I have read the CONTRIBUTING document. This file no longer exists
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

#781

Changelog Entry

WC Enhancement: add variation sku as a searchable field and apply it on the product overview list.

@kallehauge
Copy link
Contributor Author

Just a random ping in the hopes of some sort of response :-) @dinhtungdu @jeffpaul

Is the initial approach still valid in your opinion? I'm currently running with this PR on a couple of live sites

@jeffpaul jeffpaul added this to the 3.5.0 milestone Sep 1, 2020
@tlovett1
Copy link
Member

@oscarssanchez can you test this one?

@dinhtungdu
Copy link
Contributor

Hi @kallehauge, I'm sorry for this late reply! Here is the result of my test.

I tested your PR with WP 5.5.1 and WC 4.5.2. The Protected Content feature is enabled and posts are reindexed before testing.

The product search "works", but there is a problem: the formatted args is not correct, it doesn't include s but post__in. This means that the query is modified before coming to the format_args function.

Trace down the code I realize that WC uses a method named search_products that WC uses to search for products in the products admin list table, and if this method finds anything, s in query args will be unset and replace by post__in. This means that EP doesn't really search for products.

Can you confirm this behavior @kallehauge?

cc @tlovett1.

@kallehauge
Copy link
Contributor Author

kallehauge commented Sep 28, 2020

Hi @dinhtungdu,
I don't really have time to verify it for the foreseeable future. All of my resources (both at work and in private) is allocated elsewhere by now.
The PR is basically just a rewrite of the original PR by lukaspawlik so I think there - in general - might be a few issues since it was a "pretty quick port" and I wanted to know if it was still the same direction you still wished to go before I dedicated more time. But I hope it can be a good starting point for someone else

@mckdemps
Copy link
Contributor

We need to determine the current behavior of searching for a product variation SKU with ElasticPress active. Currently, WooCommerce does not perform a search query to retrieve these results, it does a direct SQL database query. If the search field fails to find parent products of a variation SKU with EP enabled, we need to figure out either how to disable this EP integration or short circuit the entire WC "search routine."

@felipeelia
Copy link
Member

Closed by #2763 and #2757.

@felipeelia felipeelia closed this May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants