Support » Plugin: CloudSearch » Add hook for additional filters

  • Plugin Contributor bheadrick

    (@bheadrick)


    I am using this to search products, and I want to be able to use the product_visibility taxonomy to control what products show up in search.

    I think I had hardcoded something to modify the filterquery a while back and forgot about it.

    I have included this taxonomy in the indexed fields, but there doesn’t seem to be any way to add such a filter to the search query.

    To get the desired effect, I have added the following to actions/cloud-search-action-search.php:275

    $search_args['filterQuery']= '(and ' . $search_args['filterQuery'] . "(not ct_product_visibility:'exclude-from-search'))";

    Adding a filter hook to this element of the array would be very useful.

    • This topic was modified 5 months, 1 week ago by bheadrick.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Andrea Landonio

    (@lando1982)

    Hi, I’ve added a filter in a new release (2.9.0).. you should add a piece of code like this:

    function add_filter_query_conditions( $extra_conditions ) {
    $extra_conditions = “(not ct_product_visibility:’exclude-from-search’)”;
    return $extra_conditions;
    };
    add_filter( ‘acs_add_filter_query_conditions’, ‘add_filter_query_conditions’, 10, 1 );

    Let me know,
    Bye

    Plugin Contributor bheadrick

    (@bheadrick)

    the resulting query of adding that filter is this:
    (and site_id:1 blog_id:1 (or post_type:’post’ post_type:’product’ (not ct_product_visibility:’exclude-from-search’)))

    so, that’s not ideal.

    if the parentheses from the last “or” clause had been closed, that would work.

    as a workaround, I got this to work:

    return ') (not ct_product_visibility:\'exclude-from-search\' ';

    While it is working, I’m seeing the following in the log.
    (re-saving the settings cleared it up)

    Undefined property: stdClass::$acs_schema_fields_legacy_types in /plugins/cloud-search/cloud-search-utils.php on line 662

    • This reply was modified 5 months ago by bheadrick.
    Plugin Author Andrea Landonio

    (@lando1982)

    Hi! Can you try the latest release (2.9.1)? Let me know if works correctly 😉

    Plugin Contributor bheadrick

    (@bheadrick)

    That works.

    I also noticed a few other undefined index errors:

    Undefined index: filter_query in cloud-search/actions/cloud-search-action-search.php on line 37
    Undefined index: extras in cloud-search/actions/cloud-search-action-search.php on line 41
    Undefined index: post_content in cloud-search/actions/cloud-search-action-search.php on line 300

    Plugin Author Andrea Landonio

    (@lando1982)

    Hi, I’ve released version 2.9.3… let me know if errors has gone away.. 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.