If this is your first visit, check our documentation. To post, register or login.
Forums / All Other Contributions/Addons / tpl_search_header does not search in the description products

tpl_search_header does not search in the description products

Started by diamond1 on 20 May 2015, 3:01 PM · Views: 1,053

Results 1 to 10 of 10
20 May 2015, 3:01 PM
#1
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

tpl_search_header does not search in the description products

I read several posts in the forum, I set to search for the file in description but nothing not search
$content .= zen_draw_hidden_field('search_in_description', '1') . zen_hide_session_id();

However if I use the advanced search works fine, to complicate matters are not able to do accept keywords to pluriale research.
thanks for the help

Giovanni,
Zen Cart V2.1

20 May 2015, 4:43 PM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: tpl_search_header does not search in the description products

diamond1:

search
$content .= zen_draw_hidden_field('search_in_description', '1') . zen_hide_session_id();

That is a very explicit search query that could easily 'fail' for many reasons.

If I were trying to find a line of code like that, my 1st query would be for
'search_in_description'

If that gave too many result for my needs, I'd narrow it down with a query:
zen_draw_hidden_field('search_in_description'

Then if needed:
$content .= zen_draw_hidden_field('search_in_description'

I can't imagine any situation where the ". zen_hide_session_id();" would be a relevant to what you are actually seeking.

Just my 2cents

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

20 May 2015, 5:35 PM
#3
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: tpl_search_header does not search in the description products

Hello Rod, I'm sorry I did not understand will be the translation, I forgot to mention that use suggestion box.

<?php
require('includes/application_top.php');

if (isset($_GET['action'])) { 
	switch($_GET['action']) {
		case 'suggestion.search':
			if (isset($_GET['keyword'])) {
				$keywords = trim($_GET['keyword']);
				$sql = "SELECT DISTINCT p.products_image, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_price_sorter, p.master_categories_id,
				               p.products_model
						  FROM ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_DESCRIPTION." pd
						 WHERE p.products_status = 1
                           AND p.products_id = pd.products_id
                           AND pd.language_id = ".(int)$_SESSION['languages_id'];
				$sql .= " AND (";
				zen_parse_search_string(stripslashes($_GET['keyword']), $search_keywords);
			    for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {
				  switch ($search_keywords[$i]) {
					case '(':
					case ')':
					case 'and':
					case 'or':
					$sql .= " " . $search_keywords[$i] . " ";
					break;
					default:
					$where_str = "(pd.products_name LIKE '%:keywords%' OR p.products_model LIKE '%:keywords%'";
			
					$sql .= $db->bindVars($where_str, ':keywords', $search_keywords[$i], 'noquotestring');
			
					$sql .= ')';
					break;
				  }
				}
				$sql .= " ) ORDER BY p.products_sort_order, pd.products_name";
				
				$result = new splitPageResults($sql, MAX_DISPLAY_SUGGESTION, 'p.products_id', 'page');
				
				if ($result->number_of_rows > 0) {
					$listing = $db->Execute($result->sql_query);				
					$show_divider = false;
					while(!$listing->EOF) {
						$image = zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], SUGGESTION_IMAGE_WIDTH, SUGGESTION_IMAGE_HEIGHT, 'class="suggestionImage"');
						$name = $listing->fields['products_name'];
						$model = $listing->fields['products_model'];
						$brand = zen_get_products_manufacturers_name($listing->fields['products_id']);
						$price = zen_get_products_display_price($listing->fields['products_id']);
						$link = zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($listing->fields['master_categories_id']) . '&products_id=' . $listing->fields['products_id']);
						if ($show_divider) { ?><hr /><?php }
						include('search_api_response.php');
						$listing->MoveNext();
						$show_divider = true;
					}
					$nextPage = (int)$result->number_of_pages != (int)$result->current_page_number;
					$prevPage = (int)$result->number_of_pages > 1 && (int)$result->current_page_number != 1;
					?>
					<div id="suggestionPaging">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr><td width="33%"><?php if ($prevPage) { ?><span id="suggestionPrev">« Prec.</span><?php } ?></td>
                                <td width="33%"><span id="suggestionCount"><?= $result->current_page_number ?> su <?= $result->number_of_pages ?> Pag.</span></td>
                                <td width="33%"><?php if ($nextPage) { ?><span id="suggestionNext">Succ. »</span><?php } ?></td>
                            </tr>
                        </table>
					</div>
					<?php
				}
			}
			break;
	}
}
require('includes/application_bottom.php');

Giovanni,
Zen Cart V2.1

25 May 2015, 7:05 PM
#4
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: tpl_search_header does not search in the description products

No one can help me? for me it is important.

Giovanni,
Zen Cart V2.1

25 May 2015, 8:55 PM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: tpl_search_header does not search in the description products

diamond1:

No one can help me? for me it is important.

I don't think we understand the question or problem that you are having.

It seems to me like you are saying that the search code doesn't search in the product descriptions. The thing is, it does do this for the rest of us, so why not you?

It could be (as per my original reply) that your search query is too specific, or perhaps you are searching for code rather than content?

I'm not sure what the purpose is for posting that code snippet. All that seems to be showing us is that the SQL does indeed search the TABLE_PRODUCTS_DESCRIPTION

How about if you provide a link to your site along with information as to what you are searching for, the results you are expecting vs the results you are getting we'll have a better idea what you are asking?

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

25 May 2015, 11:28 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: tpl_search_header does not search in the description products

If you are searching on a ZenCart frontend(customer side) for

$content .= zen_draw_hidden_field('search_in_description', '1') . zen_hide_session_id();

Then you will not get any hits
The frontend search is not intended to locate lines of code

Zen-Venom Get Bitten

26 May 2015, 9:12 AM
#7
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: tpl_search_header does not search in the description products

Thanks Rod, thanks kobra, I apologize for my bad English, I am of French mother tongue and I have to translate online and often does not translate what I write. I installed a module that displays a preview image and link product a bit like the form Numix. What I want to do is that when looking for a product in the search box header can do the research even in the product description as in advabce search. Also I'd like to adavance search form could also work there, because when your site is seen with smartphones research products header is disabled goes directly in advance search. I would like to give you the link of the website, but unfortunately the form is already installed on a test server that is blocked with IP address so RewriteCond% {REMOTE_ADDR}! ^ 83 \ .9 \ .215 \ .18 $

If you want to help me give me your IP in private that I put in to access the site.

Thank you in advance for helping.

Giovanni,
Zen Cart V2.1

26 May 2015, 6:54 PM
#8
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: tpl_search_header does not search in the description products

diamond1:

Thanks Rod, thanks kobra, I apologize for my bad English,

No need to apologise for something you have no control over. It just takes a little more patience that's all. :-)

diamond1:

What I want to do is that when looking for a product in the search box header can do the research even in the product description as in advabce search.

Aha! No problem.

Load the file
/includes/templates/YOURTEMPLATE/sideboxes/tpl_search_header.php into a text editor

Change this line

  $content .= zen_draw_hidden_field('search_in_description', '0') . zen_hide_session_id();  // Default to NOT search in description

To this

 $content .= zen_draw_hidden_field('search_in_description', '1') . zen_hide_session_id();  // Default TO search in description

diamond1:

Also I'd like to advance search form could also work there, because when your site is seen with smartphones research products header is disabled goes directly in advance search.

I'm not quite sure about this one, because whether the search box is shown in the header at all (regardless of whether viewed on a smartphone or not) is a function of whatever template/theme you are using.

Anyway, hopefully this helps solve part of the problem.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

26 May 2015, 7:09 PM
#9
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: tpl_search_header does not search in the description products

Thanks Rod, is already on 1, I once again explained hurt is I apologize. I have a drop down list when you type in the search box shows me a preview of the products without going in advance search page (as ill InstantSearch module) and it is them who do not look at the product description.
Thanks a lot

Giovanni,
Zen Cart V2.1

27 May 2015, 9:27 AM
#10
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: tpl_search_header does not search in the description products

Good morning, I finally resolved I put the solution maybe can help someone, it was enough to change this line

$where_str = "(pd.products_name LIKE '%:keywords%' OR p.products_model LIKE '%:keywords%'";

to

$where_str = "(pd.products_name LIKE '%:keywords%' OR p.products_model LIKE '%:keywords%' OR pd.products_description LIKE '%:keywords%'";

Thank you all for putting me on the right track

Giovanni,
Zen Cart V2.1