• Resolved asoutiyal

    (@asoutiyal)


    hi i want to place a particular product high on search, how can we do that? for example when a customer search a “keyword”, he should see the “product1” at the top of the search result, currently it is visible at 10th place.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Kris

    (@c0nst)

    Hi @asoutiyal

    You can add an extra score to the product by its ID, use this code snippet:

    //Add extra score to the product by ID
    add_filter( 'dgwt/wcas/search_results/product/score', function( $score, $keyword, $product_id ) {
        if ( 10 === $product_id ) {
            $score += 150;
        }
    
        return $score;
    }, 10, 3 );

    Change 10 to your product ID. You can check product ID by accessing WP Admin -> Products and hovering over the product you want to promote: https://prnt.sc/nft62rHaBdw-

    You have two ways to add this code to your theme:

    1. Open the functions.php in your child theme and add the code at the end.
    2.  or install the Code Snippets plugin and apply this code as a snippet.

    Adding an extra score to the product will move it higher. 150 extra bonus should be enough to push it to the 1st position.

    Regards,
    Kris

    Thread Starter asoutiyal

    (@asoutiyal)

    Hello sir,

    Thanks for providing the code. I have added the code in functions.php. do we need to rebuild the index after this, as currently i cannot see any change in the position yet.

    Also if we want to add multiple products in the function provided above, how can we do that.

    Kris

    (@c0nst)

    Hi @asoutiyal

    This support forum is only for users of the Free version of plugins.
    Because you’re asking about the Pro version, please submit a ticket via our website: https://fibosearch.com/contact/.

    Regards,
    Kris

    Thread Starter asoutiyal

    (@asoutiyal)

    sure i will create a ticket in the support. thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘rank a product high’ is closed to new replies.