• Resolved Tommie

    (@tsotruckstation)


    Hi,

    We have added a synonym group in the settings of Adv Woo Search, but when users search for products with other synonyms, they still unable to show in the search results.

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Tommie

    (@tsotruckstation)

    We have added a synonym group in the settings of Adv Woo Search, but when users search for products with other synonyms, they still unable to show in the search results. For example, a user search a term ‘whiskey’ that is the equivalent to the word ‘whisky’ then the right products with term of whisky should show in the search results.

    Here is the screenshot link showing the synonyms setting in Adv Woo Search:

    https://prnt.sc/vc8hzr

    Here is the search result of ‘whiskey’ that is equivalent to the word ‘whisky’ but the result shows nothing:

    https://prnt.sc/vc8qp

    Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Did you re-index plugin table after adding this synonyms groups?
    It is required to re-index after any synonyms settings changes.

    Regards

    Thread Starter Tommie

    (@tsotruckstation)

    Hi,

    Yes, we will re-index the table every time a synonym group is added, but it still does not work. Is there something we missed?

    Thanks.

    Thread Starter Tommie

    (@tsotruckstation)

    Hi,

    The synonym issue is resolved.

    One more question, is the pro version compatible with WCFM? We are interested in the user search feature. Is searching for shop vendors possible with the pro version? Will the shop vendor page being displayed on the search results?

    Thanks.

    Plugin Author ILLID

    (@mihail-barinov)

    Can you please tell me how you manage to solve this issue?

    About WCFM support – yes, with the pro pugin version it is possible to search for shop vendors and also add plugin search form to the vendrs shop page.

    About displaying vendors page on the search results page – it is depends on your current WP theme. But it is also possible to achive.

    Regards

    Thread Starter Tommie

    (@tsotruckstation)

    Hello,

    Sorry for the late reply.

    I used the theme’s default search bar, which is why the synonyms feature does not work. I have changed it to advanced woo search in the theme setting and it works well.

    About the display vendor’s page on the search results page. I am using Envato’s Martfury theme. Is it possible to achieve it? I am interested in purchasing the pro version.

    Thank you.

    Plugin Author ILLID

    (@mihail-barinov)

    @tsotruckstation

    If you are talking about showing vendors pages inside search results page – than yes, it is possible. With the pro plugin version you can use following code snippet:

    class AWS_Add_Tax {
        public $loop_start_triggered = array();
        public $current_tax = false;
        public $tax_id = 0;
        public $tax = array();
        public function __construct() {
            add_action( 'woocommerce_shop_loop', array( $this, 'woocommerce_shop_loop' ) );
            add_action( 'woocommerce_before_shop_loop_item', array( $this, 'woocommerce_shop_loop' ) );
            add_filter( 'aws_search_page_results',  array( $this, 'aws_search_page_results' ), 10, 3 );
            add_filter( 'woocommerce_loop_product_link',  array( $this, 'woocommerce_loop_product_link' ), 10 );
            add_filter( 'the_permalink',  array( $this, 'woocommerce_loop_product_link' ), 10 );
            add_filter( 'woocommerce_product_get_image',  array( $this, 'woocommerce_product_get_image' ), 10, 4 );
            add_filter( 'wp_get_attachment_image_src', array( $this, 'wp_get_attachment_image_src' ) );
            add_filter( 'woocommerce_loop_add_to_cart_link',  array( $this, 'woocommerce_loop_add_to_cart_link' ), 10, 2 );
            add_filter( 'woocommerce_sale_flash',  array( $this, 'woocommerce_sale_flash' ), 10, 3 );
            add_filter( 'woocommerce_get_price_html',  array( $this, 'woocommerce_get_price_html' ), 10, 2 );
        }
        function woocommerce_shop_loop() {
            global $product;
            if ( $product ) {
                $id = $product->get_id();
                if ( $this->current_tax && isset( $this->loop_start_triggered[$id] ) ) {
                    return;
                }
                $this->current_tax = false;
                if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                    foreach( $this->tax[$id] as $key => $tax_term ) {
                        $this->current_tax = $tax_term;
                        unset( $this->tax[$id][$key] );
                        $this->loop_start_triggered[$id] = true;
                        break;
                    }
                }
            }
        }
        public function aws_search_page_results( $posts, $query, $data ) {
            $new_posts = array();
            $product = get_posts( array(
                'posts_per_page'      => 1,
                'numberposts'         => 1,
                'fields'              => 'ids',
                'post_type'           => 'product',
                'post_status'         => 'publish',
                'ignore_sticky_posts' => true,
                'suppress_filters'    => true,
                'no_found_rows'       => 1,
                'orderby'             => 'ID',
                'order'               => 'ASC',
                'lang'                => ''
            ) );
            foreach ( $data['search_res'] as $search_res_fields ) {
                if ( isset( $search_res_fields['users'] ) ) {
                    foreach ( $search_res_fields['users'] as $tax_name => $tax_terms ) {
                        $this->tax_id = $product[0];
                        foreach ( $tax_terms as $tax_term ) {
                            $post = new stdClass();
                            $post->ID = $product[0];
                            $post->site_id = get_current_blog_id();
                            $post->post_name = $tax_term['name'];
                            $post->post_title = $tax_term['name'];
                            $post->permalink = $tax_term['link'];
                            $post->post_type = "product";
                            $post->post_author = "1";
                            $post->post_status = "publish";
                            $post->post_parent = 0;
                            $post->post_content = "";
                            $post->menu_order = 0;
                            $post->post_date = "2000-01-01 12:00:00";
                            $post->post_date_gmt = "2000-01-01 12:00:00";
                            $post->post_modified = "2000-01-01 12:00:00";
                            $post->post_modified_gmt = "2000-01-01 12:00:00";
                            $post->awssearch = true;
                            if ( $post ) {
                                $new_posts[] = $post;
                            }
                            $this->tax[$post->ID][] = $tax_term;
                        }
                    }
                }
            }
            if ( ! empty( $new_posts ) ) {
                $posts = $new_posts + $posts;
            }
            return $posts;
        }
        public function woocommerce_loop_product_link( $link ) {
            if ( $this->current_tax && isset( $this->current_tax['link'] ) ) {
                return $this->current_tax['link'];
            }
            return $link;
        }
        public function woocommerce_product_get_image( $image, $product, $size, $attr ) {
            if ( $this->current_tax ) {
                if ( isset( $this->current_tax['image'] ) ) {
                    return $image_html = '<img src="' . esc_url( $this->current_tax['image'] ) . '"/>';;
                }
                return wc_placeholder_img( $size, $attr );
            }
            return $image;
        }
        public function wp_get_attachment_image_src( $image ) {
            if ( $this->current_tax && isset( $this->current_tax['id'] ) ) {
                $post_thumbnail_id = get_post_thumbnail_id( $this->current_tax['id'] );
                remove_filter( 'wp_get_attachment_image_src', array( $this, 'wp_get_attachment_image_src' ));
                $attachment_image = wp_get_attachment_image_src( $post_thumbnail_id );
                add_filter( 'wp_get_attachment_image_src', array( $this, 'wp_get_attachment_image_src' ));
                if ( $attachment_image ) {
                    $image = $attachment_image;
                }
            }
            return $image;
        }
        public function woocommerce_loop_add_to_cart_link( $output, $product ) {
            $id = $product->get_id();
            if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                return '';
            }
            return $output;
        }
        public function woocommerce_sale_flash( $output, $post, $product ) {
            $id = $product->get_id();
            if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                return '';
            }
            return $output;
        }
        public function woocommerce_get_price_html( $output, $product ) {
            $id = $product->get_id();
            if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                return '';
            }
            return $output;
        }
    }
    new AWS_Add_Tax();
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search synonyms is not working’ is closed to new replies.