aktivsport Posted September 17, 2013 Share Posted September 17, 2013 Hello, where i can edit autocomplete search (html code) of search bar? I want to add product images to search. Thanks 1 Link to comment Share on other sites More sharing options...
Emzed Posted September 18, 2013 Share Posted September 18, 2013 (edited) Hi, I might be wrong but unfortunately I don't think it's as easy as changing some HTML and/or javascript - unless of course you customised your own image paths for each respective image ID. For an example of a simple hack see http://www.prestashop.com/forums/topic/271664-product-images-in-quick-search-results-in-prestashop-1550/, where you only need to modify \ modules \ blocksearch \ blocksearch-instantsearch.tpl. Otherwise, you'd probably have to write a few overrides. (1) You need to add to the existing query in classes\search.php (starting line 257 in v1.5.4.1 i.e. if ($ajax)...) to also extract image IDs (e.g. as 'id_image'). Since you can have several images per product, with several languages etc it's up to you how complex you make the query. If you don't care which image is used I guess you could just perform a left join to the _DB_PREFIX_image table to use the first available image, or of course "cover=1". (2) Override controllers \ front \ SeachController.php - under the loop "foreach ($searchResults as &$product)", you could add to each product's array the 'small' image link, e.g.: $product['image_link'] = $this->context->link->getImageLink($product['prewrite'],$product['id_image'],'small'); Note: I'm guessing the syntax so although this should work you should double check. (3) Edit blocksearch-instantsearch.tpl mentioned previously to add the image link e.g. basically something like: mytab[mytab.length] = { data: data, value: data.cname + ' > ' + data.pname + '<img src=\"' + data.image_link + '\" \/>' }; and change the css as you see fit. Cheers Edited September 22, 2013 by Emzed (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts