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

WooCommerce behavior in the Product Admin List View #2757

Merged
merged 6 commits into from
May 18, 2022

Conversation

felipeelia
Copy link
Member

@felipeelia felipeelia commented May 12, 2022

Description of the Change

This PR adds proper support to the WooCommerce Product Admin List Screen.

Currently, to fetch products for the admin list screen, WooCommerce, through its WC_Admin_List_Table_Products class, runs a SQL query to get a list of IDs and uses that in the main WP_Query. As ElasticPress is only involved during the WP_Query, it does not take any part in the actual search of products but only in the fetch of products matching the list of IDs.

Users wanting to keep the current behavior can add the following snippet to their codebase:

add_filter( 'ep_woocommerce_integrate_admin_products_list', '__return_false' );

By default, ElasticPress will search in products titles, content, excerpts, SKUs and their product variation SKUs. Users wanting to change that list, can use a snippet like the following:

add_filter(
	'ep_woocommerce_admin_products_list_search_fields'
	function ( $search_fields ) {
		$search_fields[] = 'post_name'; // Add post_name
		unset( $search_fields['post_title'] ); // Remove post_title
		return $search_fields;
	}
);

Closes #781

Additional Context

Some reference links were listed in this comment.

Changelog Entry

Changed: WooCommerce products list in the Dashboard now properly leverages ElasticPress.

Credits

Props @felipeelia

@felipeelia felipeelia added this to the 4.2.0 milestone May 17, 2022
@felipeelia felipeelia changed the title [WIP] WooCommerce behavior in the Product Admin List View WooCommerce behavior in the Product Admin List View May 17, 2022
Copy link
Contributor

@tott tott left a comment

Choose a reason for hiding this comment

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

This looks good to me

@felipeelia felipeelia merged commit 4528115 into develop May 18, 2022
@felipeelia felipeelia deleted the feature/admin-product-search branch May 18, 2022 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WooCommerce feature variation search on Product edit.php
2 participants