cruzer076 Posted January 11, 2013 Share Posted January 11, 2013 When I do a search for a part number, the search finds the products, displays the full part number and it work correctly. (Ajax search is working great) but.... When I search for a product name, I get the correct number of items in the search but the pictures do not display. (see attached). test here: http://www.ssilver.com/ search for "leona" I have tried: 1. re-indexed entire index 2. add missing products to index. 3. Force compile and refresh and still no change. I think it has to do with either my My Search Code Controller code...or search.tpl Am I in the right ball park? Search Controller code * International Registered Trademark & Property of PrestaShop SA */ class SearchControllerCore extends FrontController { public $php_self = 'search.php'; public $instantSearch; public $ajaxSearch; public function __construct() { parent::__construct(); $this->instantSearch = Tools::getValue('instantSearch'); $this->ajaxSearch = Tools::getValue('ajaxSearch'); } public function preProcess() { parent::preProcess(); $query = urldecode(Tools::getValue('q')); if ($this->ajaxSearch) { self::$link = new Link(); $searchResults = Search::find((int)(Tools::getValue('id_lang')), $query, 1, 10, 'position', 'desc', true); foreach ($searchResults AS &$product) $product['product_link'] = self::$link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']); die(Tools::jsonEncode($searchResults)); } if ($this->instantSearch && !is_array($query)) { $this->productSort(); $this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')))); $this->p = abs((int)(Tools::getValue('p', 1))); $search = Search::find((int)(self::$cookie->id_lang), $query, $this->p, $this->n, $this->orderBy, $this->orderWay); Module::hookExec('search', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total']; $this->pagination($nbProducts); self::$smarty->assign(array( 'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'instantSearch' => $this->instantSearch, 'homeSize' => Image::getSize('home'))); } elseif ($query = Tools::getValue('search_query', Tools::getValue('ref')) AND !is_array($query)) { $this->productSort(); $this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')))); $this->p = abs((int)(Tools::getValue('p', 1))); $search = Search::find((int)(self::$cookie->id_lang), $query, $this->p, $this->n, $this->orderBy, $this->orderWay); Module::hookExec('search', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total']; $this->pagination($nbProducts); self::$smarty->assign(array( 'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'homeSize' => Image::getSize('home'))); } elseif ($tag = urldecode(Tools::getValue('tag')) AND !is_array($tag)) { $nbProducts = (int)(Search::searchTag((int)(self::$cookie->id_lang), $tag, true)); $this->pagination($nbProducts); $result = Search::searchTag((int)(self::$cookie->id_lang), $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay); Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result))); self::$smarty->assign(array( 'search_tag' => $tag, 'products' => $result, // DEPRECATED (since to 1.4), not use this: conflict with block_cart module 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home'))); } else { self::$smarty->assign(array( 'products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0)); } self::$smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')); } public function displayHeader() { if (!$this->instantSearch AND !$this->ajaxSearch) parent::displayHeader(); else self::$smarty->assign('static_token', Tools::getToken(false)); } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'search.tpl'); } public function displayFooter() { if (!$this->instantSearch AND !$this->ajaxSearch) parent::displayFooter(); } public function setMedia() { parent::setMedia(); if (!$this->instantSearch AND !$this->ajaxSearch) Tools::addCSS(_THEME_CSS_DIR_.'product_list.css'); } } Search TPL {capture name=path}{l s='Search'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <h1 {if isset($instantSearch) && $instantSearch}id="instant_search_results"{/if}> {l s='Search'} {if $nbProducts > 0}"{if isset($search_query) && $search_query}{$search_query|escape:'htmlall':'UTF-8'}{elseif $search_tag}{$search_tag|escape:'htmlall':'UTF-8'}{elseif $ref}{$ref|escape:'htmlall':'UTF-8'}{/if}"{/if} {if isset($instantSearch) && $instantSearch}<a href="#" class="close">{l s='Return to previous page'}</a>{/if} </h1> {include file="$tpl_dir./errors.tpl"} {if !$nbProducts} <p class="warning"> {if isset($search_query) && $search_query} {l s='No results found for your search'} "{if isset($search_query)}{$search_query|escape:'htmlall':'UTF-8'}{/if}" {elseif isset($search_tag) && $search_tag} {l s='No results found for your search'} "{$search_tag|escape:'htmlall':'UTF-8'}" {else} {l s='Please type a search keyword'} {/if} </p> {else} <h3><span class="big">{$nbProducts|intval}</span> {if $nbProducts == 1}{l s='result has been found.'}{else}{l s='results have been found.'}{/if}</h3> {if !isset($instantSearch) || (isset($instantSearch) && !$instantSearch)}{include file="$tpl_dir./product-sort.tpl"}{/if} {include file="$tpl_dir./product-list.tpl" products=$search_products} {if !isset($instantSearch) || (isset($instantSearch) && !$instantSearch)}{include file="$tpl_dir./pagination.tpl"}{/if} {/if} Link to comment Share on other sites More sharing options...
clayton29657 Posted January 11, 2013 Share Posted January 11, 2013 Hello cruzer076 I am not sure why it's not showing a picture but I did want to tell you that if you've the product names the same it's going to show duplicates in google. just wanted to let you know in case you do not know. Cheers Clayton Link to comment Share on other sites More sharing options...
cruzer076 Posted January 11, 2013 Author Share Posted January 11, 2013 Hey Clayton, thanks for the heads up, We have done things a little different, a product name is really the product line.. I.e. Leona is a set of tables, chairs and side desks, each one is part of the "Leona" collection. This would be a separate subject but the best way I figured to do collections was to use attributes and the products are really attributes. So Leona is a Product Attribute 1: Table Top $500 Attribute 2: Chair: 29.00 Etc...I didn't want to have a separate "product image" when searching the through the catalog, Make sense? Is there a better way to show colletions? Yes, this search things is weird, can't figure it out Link to comment Share on other sites More sharing options...
Recommended Posts