Jump to content

In which file the code of default HOOK "search" is written?


Recommended Posts

PrestaShop doesn't have a hook that lets you access search results and modify them. You'll need to create override/classes/Search.php with the following:

<?php

class Search extends SearchCore
{
    public static function find($id_lang, $expr, $page_number = 1, $page_size = 1, $order_by = 'position',
        $order_way = 'desc', $ajax = false, $use_cookie = true, Context $context = null)
    {
        $return = parent::find($id_lang, $expr, $page_number, $page_size, $order_by, $order_way, $ajax, $use_cookie, $context);
        
        $total = $return['total'];
        $result = $return['result'];
        
        // Modify total and result here
        
        return array('total' => $total, 'result' => $result);
    }
   
}

If you're writing a module, you can put this override inside your module's directory and it will automatically be copied when the module is installed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...