-
Notifications
You must be signed in to change notification settings - Fork 316
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
How to get aggregates #3822
Comments
So what i left out above is that I was running that code from a php file in the terminal (wp-load included!), but it seems i needed to add this to ensure facets would work: add_filter( 'ep_is_facetable', '__return_true' ); If you search for this you will see there's an exclusion against WP CLI for faceting. Took inspiration from here @ #3352 I still think the aggregations functionality could be better documented! |
Hi @gosixl, you are totally right. The aggregations functionality is something we need to document better. For now, can you please try to debug it using this snippet? Thanks! add_filter(
'ep_es_query_results',
function ( $results, $response, $query, $query_args, $query_object ) {
print_r( $results );
print_r( $response );
return $results;
},
10,
5
); The $query_object variable is your WP_Query object, so you can create a relationship between them in that function if you need to. |
I found $GLOBALS['ep_facet_aggs'] to be an okay solution. Is that a good idea? |
That works @gosixl, but only because you have |
Got it - thank you Felipe
… On 27 Feb 2024, at 17:42, Felipe Elia ***@***.***> wrote:
That works @gosixl <https://github.com/gosixl>, but only because you have add_filter( 'ep_is_facetable', '__return_true' ); there. If you don't plan to use facets/filters, the ep_es_query_results approach would be preferable.
—
Reply to this email directly, view it on GitHub <#3822 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AVBQ54G4GIBD3WBKW4KX42LYVYLHZAVCNFSM6AAAAABCQEWUJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRXGI3TQOBTG4>.
You are receiving this because you were mentioned.
|
Describe your question
Hello.. getting total aggregations is really undocumented and challenging to find for a new user of this plugin.
I just want to work out, for a product query, I'd like the total counts for the terms for the taxonomies on my woocommerce.
I've tried this code cobbled from googling around.
Outputs for 1 and 3 are empty arrays. (For 3:
PHP Warning: Undefined global variable $ep_facet_aggs
)Output for 2 below (kept to 1 post out for brevity):
Code of Conduct
The text was updated successfully, but these errors were encountered: