Jump to content

Search Results Not Returning Searched For Combination


coziosco

Recommended Posts

Hi

 

I've been trying to dial out an issue I'm having with a search by reference code for products with combinations. e.g. if I have 3 colour combinations of a product each with it's own reference:

 

ORT10

ORT11

ORT12

 

Searching for any of the reference codes returns the overview of the product correctly which can then be clicked to view details and then select the combination but I'd expect the functionality of this to take you straight to the actual combination you searched for. Far better for end users.

 

Any thoughts?

Cheers

C

Link to comment
Share on other sites

The search returns a list of products. If it is a precise key, the result might contain only one product. However only when clicking on the product the product detail page opens.  At the time you click on the product your server doesn't know much about the previous search.

 

To avoid that you had to override the search class in order to skip the product list if the result contains only one record and open the product witth the corresponding combination.

  • Like 1
Link to comment
Share on other sites

I think is rather to be applied on the SearchController.php and not the Search class. Somewhere after this

    Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));

You need to check the number products, grab all needed data for product and attribute and pass this to product.tpl.

    if ( $search['total'] == 1  ) {
      // fetch product and attribute (if exists)
      // assingn tpl variables
      $this->context->smarty->assign(array(.... needed array data))
      // display product.tpl instead of search tpl
        $this->setTemplate(_PS_THEME_DIR_.'product.tpl');
        return;
    }

It's just a rough guide not a complete code.

Link to comment
Share on other sites

  • 4 years later...
  • 5 months later...

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...