• There appears to be a conflict with the latest version of WooCommerce, all variations are appearing in the search results, including the main product. Please can this be fixed asap?

    Steve

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • undergroundengland123

    (@undergroundengland123)

    Hi Steve,

    Likewise, no response either, appears from their website that Plugin development is not their main activity and we noted it has been sometime since this Plugin has been updated.

    We have deactivated the plugin and the issue with front-end search now works without issue, also if we enter a SKU the result is also displayed!

    Regards
    Peter

    Thread Starter steveindzine

    (@steveindzine)

    Hi Peter,
    I will give it a try myself, see if we can still search by SKU. Maybe WooCommerce has added this in recently?

    Steve

    Thread Starter steveindzine

    (@steveindzine)

    Hi Peter,

    Sadly disabling the plugin has prevented my ability to search by SKU ??

    Steve

    Same issue here, it seems that the plugin will show on search results all the variations too… but that could be ok because all my variations have their own sku so, when you search for one of them, it can be correct to show all of them or the one that has that specific sku (variation sku could completely differ from main product sku too…)

    The real problem for me is that variations on search results are not showing product image and during search so I have a wall of “placeholder” due to this bug.

    I think this is the real issue that has to be fixed here and the “variation” issue is “working as intended” by developers.

    For the plugin developers: could you please fix the image issue?
    Maybe I can help with the code but I need to study it and maybe it’s simple to fix the issue for you that know the code, thanks (if you need help let me know).

    Waiting for more informations or updates, Regards!

    Marco

    Thread Starter steveindzine

    (@steveindzine)

    @brennino you may want to start a new thread to get the developers attention, as it hasn’t worked so far.

    • This reply was modified 2 years, 8 months ago by steveindzine.
    Plugin Author mattsgarage

    (@mattsgarage)

    Hi @steveindzine, thanks for flagging. It sounds like something in the latest woocommerce must have changed how the search queries work. I can’t guarantee any timelines on fixing this issue but I am registering here that I’m aware of the issue and plan to fix it.

    @brennino Also, thanks for flagging. If you want to take a look at the code it is here and PR’s welcome: https://github.com/matthewlawson/search-by-sku-for-woocommerce

    Thread Starter steveindzine

    (@steveindzine)

    @mattsgarage thank you for the update, I will let my client know you are on it. If you need help testing your resolution I am happy to setup a staging site.

    Steve

    I can confirm that I am also having the same problem.

    Hi, I was also wondering if you’ve identified the problem and have a loose idea of when it might be corrected. Thanks.

    As an alternative to wait for the plugin to be fixed, I found adding this to your child themes functions.php file worked (don’t forget to deactivate this plugin first):

    function search_by_sku( $search, $query_vars ) {
        global $wpdb;
        if(isset($query_vars->query['s']) && !empty($query_vars->query['s'])){
            $args = array(
                 'post_type'       => 'product',
                'meta_query' => array(
                    array(
                        'key' => '_sku',
                        'value' => $query_vars->query['s'],
                        'compare' => 'LIKE'
                    )
                )
            );
            $posts = get_posts($args);
            if(empty($posts)) return $search;
            $get_post_ids = array();
            foreach($posts as $post){
                $get_post_ids[] = $post->ID;
            }
            if(sizeof( $get_post_ids ) > 0 ) {
                    $search = str_replace( 'AND (((', "AND ((({$wpdb->posts}.ID IN (" . implode( ',', $get_post_ids ) . ")) OR (", $search);
            }
        }
        return $search;
    }
    add_filter( 'posts_search', 'search_by_sku', 999, 2 );

    It will change your entire site search to only search products, so if this is ok for you, this is a good solution.

    Steve

    Hi Matt, I’m experiencing the same problem and see that this is still not fixed, the last update for the plugin is now 10 months ago…

    Any chance you’ll be able to get an update with a fix for this one of the coming weeks?

    Thank you very much!

    Frederic

    @dooza Thanks for the code.

    Need to add a parameter ‘numberposts’ => -1.
    By default, only five data will be found. [1]

    [1] https://developer.www.ads-software.com/reference/functions/get_posts/#parameters

    @mattsgarage I’ve created a pull request with a fix for this issue. Please, have a look whenever you can and accept it if it’s ok. Thank you!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘All variations are appearing in search’ is closed to new replies.