Jump to content

Recommended Posts

Hi,

 

When searching in Prestashop and no results are found, is it possible to then redirect to the Prestashop contact us form with some custom writing on the page (We apologies that the search result came up empty, please fill in the contact form below and we will try our best to assist you in getting the product you are looking for).

 

Any help would be greatly appreciated!

Link to comment
Share on other sites

replace ur search.tpl from default folder to this on javascript put url on ur contact us page

{*

* 2007-2013 PrestaShop

*

* NOTICE OF LICENSE

*

* This source file is subject to the Academic Free License (AFL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.or...ses/afl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to [email protected] so we can send you a copy immediately.

*

* DISCLAIMER

*

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <[email protected]>

* @copyright 2007-2013 PrestaShop SA

* @license http://opensource.or...ses/afl-3.0.php Academic Free License (AFL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*}

 

{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 the 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 were 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 were found for your search'} "{$search_tag|escape:'htmlall':'UTF-8'}"

{else}

{l s='Please enter a search keyword'}

{/if}

</p>

<p><a href="{$link->getPageLink('contact', true)}" title="{l s='contact us'}"><img src="{$img_dir}icon/home.gif" /> {l s='contact us'}</a></p><input type='button' class="button" value='back' onclick='history.back()'>

<script type="text/javascript">

<!--

window.location="ursite.com/contactus";

//-->

</script>

{else}

<h3 class="nbresult"><span class="big">{if $nbProducts == 1}{l s='%d result has been found.' sprintf=$nbProducts|intval}{else}{l s='%d results have been found.' sprintf=$nbProducts|intval}{/if}</span></h3>

{include file="./product-compare.tpl"}

{if !isset($instantSearch) || (isset($instantSearch) && !$instantSearch)}

<div class="sortPagiBar clearfix">

{include file="$tpl_dir./product-sort.tpl"}

</div>

{/if}

 

{include file="$tpl_dir./product-list.tpl" products=$search_products}

{if !isset($instantSearch) || (isset($instantSearch) && !$instantSearch)}{include file="$tpl_dir./pagination.tpl"}{/if}

{include file="./product-compare.tpl"}

{/if}

Edited by Jiten rash (see edit history)
Link to comment
Share on other sites

and if you want to add message box with information that no result found in contact page

in this case you have to redirect user to page contact-us with additional get param, for example: &search=noresults

 

instead:

<script type="text/javascript">
<!--
window.location="ursite.com/contactus";
//-->
</script>

 

use this:

<script type="text/javascript">
<!--
window.location="{$link->getPageLink('contact',false,null,'search=noresults')}";
//-->
</script>

 

 

then in contact.tpl page use this:

 

{if Tools::getValue('search')=="noresults"}
<p class="warning">{l s='Sorry, no results found. please contact with us.'}</p>
{/if}

Link to comment
Share on other sites

  • 1 month later...

Thank you very much, your post helped me big time to get this working!

 

Just one question, is it possible to have the search query remain in the search field after the redirect? This will allow my users to edit their search rather than retype it out.

Link to comment
Share on other sites

it is possible but in this case you will have edit .tpl file and also change the return page a bit. Just pass additional variable in the url

search=noresults&query=USER_QUERY_HERE

 

then in search field (block search module .tpl file) user {$smarty.get.query}

Link to comment
Share on other sites

Hi Vekia,

 

Thanks for your fast reply.

 

Unfortunatly i am not understanding you 100%. Do you mean add

search=noresults&query=USER_QUERY_HERE

to the search.tpl or contact-form.tpl in the URL window.location={......}

 

And where should i add {$smarty.get.query} in the /modules/blocksearch/blocksearch.tpl?

Link to comment
Share on other sites

  • 1 year later...

Hi !

 

I need to do exactly the same things (redirect to a page when there are no results). But in the current version there is no search.tpl, and there isn't any of the files who looks like that. Can you help me ?

 

Thanks

Link to comment
Share on other sites

  • 3 years later...

Hi everyone!

In my case, I want that the search module show the results because now, always redirect to the home page and I don't know why! I mean, the search module doesn't work!

Can any help? I tried to uninstall, and reinstall, clean caché, etc ... but nothing, the same thing. When you search any thing always redirect to the home :(:(

Thanks in advance!

Holle

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