• Hello. I have faced this issue: Through ajax search does not find some products by some names (for example Dionysus, marmont, Matelasse, GG), but if I enter the query Dionysus bag, then in ajax search I see the necessary results. Normal search (by clicking on the Search button works fine). Also, if I enter the word “GG” I don’t see any results in the ajax search, but if I enter “LP” I see results.

    For the test I changed the name on one product from: GG Dionysus Small 25cm Shoulder Bag to: GG Abrakada Small 25cm Shoulder Bag and now that item appears in the instant search results. But when I changed the name back to Dionysus it stopped finding again.

    In the plugin settings I disabled caching of results, also I tried to re-index tables, remove the check for misspellings, change query hook.Also for the test I disabled almost all plugins, leaving only Woocommerce+Woo Adv Search + Kadence.

    https://postimg.cc/gwmpFk5M

    https://postimg.cc/WD8v2ccs

    https://postimg.cc/FdKQzCh3

    https://postimg.cc/ph1MFQd7

    https://postimg.cc/PNPjk73k

    https://postimg.cc/5QYdqHYt

    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Yes, it is indeed a strange problem.

    Please tell me – are you using any custom code snippets to customize plugin search results output?

    Also – can you show me screenshots of the plugin settings page?

    Regards

    Thread Starter oswoptimize

    (@oswoptimize)

    Yeah you are right, the problem is a conflict with the snippet. I have a product type ‘discontinued’ in my store and I used this snippet to exclude products with this status from the search results. The problem is that for normal search it works fine, but in ajax search it causes problems. Could you please tell me which snippet I can use to exclude items with discontinued status from ajax search results?

    I have enabled logging and I see that the states are detected correctly (for normal search).
    [08-Oct-2024 14:53:42 UTC] Product ID: 4619 has status: instock
    [08-Oct-2024 14:53:42 UTC] Product ID: 1620 has status: outofstock
    [08-Oct-2024 14:53:42 UTC] Product ID: 1603 has status: discontinued
    [08-Oct-2024 14:53:42 UTC] Number of products after filtering: 2

    Problem snippet:

    //Hide item with Discontinued status from aws search
    add_filter( 'aws_search_results_products', 'aws_search_results_products', 10, 2 );
    function aws_search_results_products( $products, $s ) {
    $filtered_products = array();

    foreach ( $products as $product ) {
    $product_id = $product['id'];
    $product_status = wc_get_product( $product_id )->get_stock_status();

    if ( 'discontinued' !== $product_status ) {
    $filtered_products[] = $product;
    }
    }

    return $filtered_products;
    }

    Settings:

    https://postimg.cc/JGsttwJQ

    https://postimg.cc/D4Z0qHNn

    https://postimg.cc/K4v1S38w

    https://postimg.cc/hhyfS4Jj

    Thank you,

    Anton

    Plugin Author ILLID

    (@mihail-barinov)

    I see. Please try to use this code snippet instead:

    add_filter( 'aws_search_results_products_ids', 'aws_search_results_products_ids', 10, 2 );
    function aws_search_results_products_ids( $products, $s ) {
    $filtered_products = array();
    foreach ( $products as $product_id ) {
    $product_status = wc_get_product( $product_id )->get_stock_status();
    if ( 'discontinued' !== $product_status ) {
    $filtered_products[] = $product_id;
    }
    }
    return $filtered_products;
    }
    Thread Starter oswoptimize

    (@oswoptimize)

    Unfortunately the result is the same. It doesn’t work for ajax search (Search result – nothing found), but it works for normal search.

    Plugin Author ILLID

    (@mihail-barinov)

    So did you remove your previous code snippet?

    Also – do you see any errors inside your debug.log file?

    Thread Starter oswoptimize

    (@oswoptimize)

    So did you remove your previous code snippet? – Of course

    Also – do you see any errors inside your debug.log file? I added lines in config.php + reindexed the tables, but the debug.log code didn’t show up.

    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    Thread Starter oswoptimize

    (@oswoptimize)

    I can give you access to the staging site if it is convenient for you.

    Plugin Author ILLID

    (@mihail-barinov)

    Sorry, it is not allowed on this forum.

    So with this updated snippet work fine for search page and not working only for ajax? Do you have any other code snippets except this one?

    Thread Starter oswoptimize

    (@oswoptimize)

    The updated snippet works the same as my initial snippet (ok for normal search, but doesn’t work for ajax search).

    No, all the other snippets are not related to this problem (I removed them too for the test).

    Thread Starter oswoptimize

    (@oswoptimize)

    I’ve solved the problem.

    I cleaned the whole site from all codes/plugins, installed the twenty-two theme, but the search bug didn’t go away. Also the usual snippet to exclude a product by ID did not work.

    After that I removed from search source and search table all the unnecessary data (SKU, tag, ID, short description) and everything worked.

    Plugin Author ILLID

    (@mihail-barinov)

    Well, that’s strange if that unnecessary data removal helps you. Data from the index table is not correlated with your code snippet for filtering search results. But I am glad that you were able to solve the problem.

    Thread Starter oswoptimize

    (@oswoptimize)

    I realize that there shouldn’t have been a connection here. Nevertheless, this solution helped on the live site too ??

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