WPSolr logo
Search
Close this search box.

Forum Replies Created

  • HaikoG
    Participant

    Ok, I’ve tried to find the problem and got a solution

    In

    Replace
    add_action( ‘wp_ajax_yith_ajax_search_products’, [ $this, ‘ajax_search_products’ ], 9 );
    add_action( ‘wp_ajax_nopriv_yith_ajax_search_products’, [ $this, ‘ajax_search_products’ ], 9 );

    with
    if ( ! isset( $_REQUEST[‘wc-ajax’] ) ) {
    add_action( ‘wp_ajax_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ), 9);
    add_action( ‘wp_ajax_nopriv_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ), 9 );
    } else {
    add_action( ‘wc_ajax_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ) , 9);
    }

    and

    $wpsolr_query->query[‘s’] = $query->query[‘s’];
    with
    $wpsolr_query->query[‘s’] = $_REQUEST[‘query’];

    Don’t know if this still works for the free version, but it does for the premium so if anyone runs in to this you can use this

    HaikoG
    Participant

    In the Solr index we’ve added a ‘pricelist_id’, which is used to filter results per usergroup. So, every user has a certain pricelist which dictates which products they see. We’re also indexing the SKU and EAN number of the products. This worked perfectly with WPSolr and the free version of YITH Woocommerce ajax search:

    – Searching a regular product like phone, showed only phones from within the users’ pricelist; Also in the suggestions box.
    – Searching a SKU that’s not in users pricelist, showed ‘No results’, as it should
    – Searching a SKU that is available in the users’ pricelist showed that product, as it should.

    Now we wanted to show the image of the product in the suggestion box. As YITH is used for the suggestion box, I looked in this plugin for the answer, which turned out the free version of YITH can’t do that. So we upgraded the plugin.

    Now the suggestion box is no longer showing the Solr results, but searches the entire product database.

    – Searching a regular product like phone, now shows all product with phone in the title in the suggestion box. But when actually pressing search, we get the filtered Solr results.
    – Searching a SKU that’s not in users pricelist, shows ‘No results’, as it should
    – Searching a SKU that is available in the users’ pricelist now says ‘No results’ when it should show a product. But when I click search, it shows the correct product.

    So this is telling me te suggestionsbox / Yith is no longer using WPSOLR as search engine, but rather the old/regular WP query.

    HaikoG
    Participant
    4 years, 3 months ago in reply to: Posts per page #15956

    I figured it out.. The getter and the setter aren’t named equal

    $wpsolr_query->get_nb_results_by_page() gets the result
    $wpsolr_query->wpsolr_set_nb_results_by_page() sets the result. notice the wpsolr in the functionname?

    For consistency it would be nice to have these kind of functions named similar, but I caught it for this one 🙂

    HaikoG
    Participant
    4 years, 3 months ago in reply to: v20.8 facets issue with classnames #15954

    It was resolved by disabling a SAML plugin. Not sure why though, but for now it is resolved.

    Thanks

    HaikoG
    Participant
    4 years, 4 months ago in reply to: v20.8 facets issue with classnames #15929

    We do have some custom code running, but turning that off did not change the behaviour. The only code interacting with the facets is

    add_filter( WPSOLR_Events::WPSOLR_FILTER_UPDATE_FACETS_DATA, ‘hg_filter_facet_items’, 10, 1);

    function hg_filter_facet_items($facets){
    // loop through array in array in array
    foreach ($facets as $fkey => $facet){
    if (is_array($facet)){
    foreach ($facet as $fikey => $facet_item){
    if (isset($facet_item[‘id’]) && $facet_item[‘id’] == ‘product_cat_str’){
    // get terms that are allowed to be filtered (hide customer specific categories)
    $show_terms = get_terms( ‘product_cat’, array(‘meta_key’ => ‘include_in_queryfilters’, ‘meta_value’ => 1) );
    foreach ($facet_item[‘items’] as $itemkey => $item){
    if (!in_array($item[‘value’], array_column($show_terms, ‘name’))){
    unset($facets[$fkey][$fikey][‘items’][$itemkey]);
    }
    }
    }
    }

    }
    }

    return $facets;
    }

    I’ll try turning off some other customizations

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facet count is wrong when a text query is used #14780

    I just found that when I enable ‘Use fuzzy keyword matches in results’ I do get the results, only the user has no way of knowing their search keyword was changed as I can’t get that text to show up

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facet count is wrong when a text query is used #14777

    Ok, I found a clue 🙂

    I think search suggestions has something to do with this. I found this in the query object
    [corrections:protected] => Array
    (
    [gerard] => gehard
    )

    Gehard is Dutch for hardened which is actually a word that’s used in our descriptions. When searching for ‘Gehard’ I get results and the exact same facets and facet counts. This looks like the facets are using the correction, but the results are not.

    What can I do to let the search use the correction as well?

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facet count is wrong when a text query is used #14776

    I tried looking in the code, but it is unclear to me how to do that.
    When looking at the query though, I do see Query Filters for type:product

    [filterQueries:protected] => Array
    (
    [authorized indexed types] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    )

    [query:protected] => type:(“product”)
    [options:protected] => Array
    (
    [query] => type:(“product”)
    [key] => authorized indexed types
    )

    )

    [bad_statuses] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    )

    [query:protected] => -post_status_s:(“draft” OR “pending” OR “trash” OR “future” OR “private” OR “auto-draft”)
    [options:protected] => Array
    (
    [key] => bad_statuses
    [query] => -post_status_s:(“draft” OR “pending” OR “trash” OR “future” OR “private” OR “auto-draft”)
    )

    )

    [pricelist_ids:”1″] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    [] => 1
    )

    [query:protected] => pricelist_ids:”1″
    [options:protected] => Array
    (
    [key] => pricelist_ids:”1″
    [query] => pricelist_ids:”1″
    [tag] =>
    )

    )

    [type:”product”] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    [] => 1
    )

    [query:protected] => type:”product”
    [options:protected] => Array
    (
    [key] => type:”product”
    [query] => type:”product”
    [tag] =>
    )

    )

    [woocommerce type:product] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    [] => 1
    )

    [query:protected] => type:”product”
    [options:protected] => Array
    (
    [key] => woocommerce type:product
    [query] => type:”product”
    [tag] =>
    )

    )

    [woocommerce catalog visibility] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    )

    [query:protected] => ((*:* -product_visibility_str:*) OR -product_visibility_str:(exclude-from-search))
    [options:protected] => Array
    (
    [key] => woocommerce catalog visibility
    [query] => ((*:* -product_visibility_str:*) OR -product_visibility_str:(exclude-from-search))
    )

    )

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facet count is wrong when a text query is used #14772

    Yes, the woocommerce extension is activated.

    Is there a way to check the raw results coming from Solr? If I print_r the solr_query from WPSOLR_Events::WPSOLR_ACTION_SOLARIUM_QUERY I do see queryfilters for type:product

    • This reply was modified 4 years, 6 months ago by wpsolr. Reason: removed long print_r
    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facet count is wrong when a text query is used #14767

    That’s WPSOLR PRO 21.6 and Solr 7.3.1

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facets not ‘stacking’ #14629

    Yes! It works!
    Many many many thanks for the support and patience 🙂

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facets not ‘stacking’ #14627

    Ok, so I disabled plugins one by one, which didn’t do much at first. I began activating plugins again and all of the sudden it worked. All plugins are activated as they were, and still working.

    So now I can filter on White Samsungs 🙂

    Somehow I can still select one item per taxonomy though, so it is not possible to filter on white LG’s and Samsungs. Could that be related to the schema.xml?

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facets not ‘stacking’ #14625

    No, that not checked. I tried by checking it and searching again but that did not make any change unfortunately

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facets not ‘stacking’ #14623

    Yes, on the search page the same happens.
    I can uncheck the box at “Hide when only one choice remains.”, then it stays but only with the selected choice

    HaikoG
    Participant
    4 years, 6 months ago in reply to: Facets not ‘stacking’ #14621

    Ok, so I found something;
    If I change the layout of the filter from checkboxes to select (select2.js and regular) I’m able to “stack” the filters, but only the filters which have the select layout get stacked. The filter from the checkbox is overridden when selecting an other.

    I do like to use the checkbox layout though, UX wise that makes more sense

Viewing 15 posts - 16 through 30 (of 36 total)