Forums / Templates, Stylesheets, Page Layout / Advanced Search - customized product fields?

Advanced Search - customized product fields?

Started by zvenson on 2 Jul 2009, 3:34 AM · Views: 17,571

Results 21 to 40 of 52
21 Jul 2009, 1:53 AM
#21
zvenson avatar

zvenson

New Zenner

Join Date:
May 2009
Posts:
61
Plugin Contributions:
0

Advanced Search - customized product fields?

Hi!
If the search page doesn`t go to the result page there must be something wrong in your
tpl_advanced_search_default.php file
or the
/include/modules/pages/advanced_search/header_php.php

you didn`t post your changes there, right?

and if your sure about the value of "dwarf" isn`t string than string is def. not the right variable type - but string should work as well (i think).

these are the possible variable types in php (as far as i know):
"array"
"double"
"integer"
"object"
"resource"
"string"
"unknown type"

www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

4 Aug 2009, 3:08 AM
#22
zvenson avatar

zvenson

New Zenner

Join Date:
May 2009
Posts:
61
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

found another issue while testing my advanced search in different languages -
if you just want to search on of your "advanced search features" without a searchterm in the keywords section and you are using a different language than english, you have to replace a value in
/includes/languages/YOUR_Language/advanced_search.php

from
define('KEYWORD_FORMAT_STRING', 'Schlüsselworte');
to
define('KEYWORD_FORMAT_STRING', 'keywords');

otherwise the shop searches for the search term "Schlüsselworte" (for the german example) and that leads to wrong results
hope this helps someone.
br
zvenson

www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

4 Aug 2009, 3:39 PM
#23
rajoo_sharma avatar

rajoo_sharma

Zen Follower

Join Date:
Aug 2009
Posts:
137
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

It may not be appropriate for everyone, but I think it can be very simple. Do not add any extra text boxes for custom fields for example products_author.

  1. includes/modules/pages/advanced_search_result/header_php.php

Find:
$where_str .= "(pd.products_name LIKE '%:keywords%'

After:

OR p.products_model
LIKE '%:keywords%'

Add:
OR p.products_author
LIKE '%:keywords%'

  1. includes/languages/your_template/advanced_search.php

Replace:

define('HEADING_SEARCH_CRITERIA', 'Choose Your Search Terms');

with:

define('HEADING_SEARCH_CRITERIA', 'Title, Author, ISBN/ISSN');

5 Aug 2009, 6:44 AM
#24
zvenson avatar

zvenson

New Zenner

Join Date:
May 2009
Posts:
61
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

Hi rajoo.sharma !
Thanks for this - it is a different attempt but should work as well for some people. In my case I needed a little more advanced search where you can specify different values and a description the same time without using the "AND" thing in the description field..
And I needed to search extra database tables.
But your solution is good and simple and should be much easier to implement then what i came up with...:bigups:
cheers!

www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

6 Oct 2009, 2:38 PM
#25
kblckmr avatar

kblckmr

New Zenner

Join Date:
May 2009
Posts:
9
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

Hi Guys,
I've been playing with my advanced search file to see if I could just search categories meta tags and descriptions. I was following this post as well as this one...

http://www.zen-cart.com/forum/showthread.php?t=114787

I've made some changes and have run into this output

1146 Table 'lim0908902331618.TABLE_META_TAGS_CATEGORIES_DESCRIPTION' doesn't exist
in:
[select count(distinct p.products_id) as total FROM (zen_products p LEFT JOIN zen_manufacturers m USING(manufacturers_id), zen_products_description pd, zen_categories c, zen_products_to_categories p2c ) LEFT JOIN zen_meta_tags_products_description mtpd ON mtpd.products_id= p2c.products_id AND mtpd.language_id = 1 LEFT JOIN TABLE_META_TAGS_CATEGORIES_DESCRIPTION mtcd ON mtcd.categories_id= c.categories_id AND mtcd.language_id = 1 WHERE (p.products_status = 1 AND p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_id = p2c.products_id AND p2c.categories_id = c.categories_id AND c.categories_id = mtcd.categories_id AND ((pd.products_name LIKE '%boy%' OR p.products_model LIKE '%boy%' OR m.manufacturers_name LIKE '%boy%' OR (mtpd.metatags_keywords LIKE '%boy%' AND mtpd.metatags_keywords !='') OR (mtcd.metatags_keywords LIKE '%boy%' AND mtcd.metatags_keywords !='') OR (mtpd.metatags_description LIKE '%boy%' AND mtpd.metatags_description !='') OR pd.products_description LIKE '%boy%') ))]

I'm not an SQL girl so I'm not sure how to resolve this issue although I did confirm that the table META_TAGS_CATEGORIES_DESCRIPTION is there. I must be referencing / linking it wrong in the query code. Any ideas?

6 Oct 2009, 4:39 PM
#26
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Advanced Search - customized product fields?

The constant for that table is:
TABLE_METATAGS_CATEGORIES_DESCRIPTION

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Oct 2009, 5:49 PM
#27
kblckmr avatar

kblckmr

New Zenner

Join Date:
May 2009
Posts:
9
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

Thank you! By the way how did you know that? Is it located in myphpadmin somewhere?

6 Oct 2009, 6:34 PM
#28
kblckmr avatar

kblckmr

New Zenner

Join Date:
May 2009
Posts:
9
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

oh gosh, could I bother you again...

I'm getting this result now...

1054 Unknown column 'cd.categories_id' in 'where clause'
in:
[select count(distinct p.products_id) as total FROM (zen_products p LEFT JOIN zen_manufacturers m USING(manufacturers_id), zen_products_description pd, zen_categories c, zen_products_to_categories p2c ) LEFT JOIN zen_meta_tags_products_description mtpd ON mtpd.products_id= p2c.products_id AND mtpd.language_id = 1 LEFT JOIN zen_meta_tags_categories_description mtcd ON cd.categories_id= c.categories_id AND dc.language_id = 1 WHERE (c.categories_status = 1 AND p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_id = p2c.products_id AND p2c.categories_id = c.categories_id AND c.categories_id = cd.categories_id AND c.categories_id = dc.categories_id AND ((cd.metatags_description LIKE '%infant%' OR cd.metatags_keywords LIKE '%infant%' OR dc.categories_name LIKE '%infant%' OR cd.metatags_title LIKE '%infant%' OR (mtpd.metatags_keywords LIKE '%infant%' AND mtpd.metatags_keywords !='') OR (mtpd.metatags_description LIKE '%infant%' AND mtpd.metatags_description !='') OR pd.products_description LIKE '%infant%') ))]

6 Oct 2009, 8:06 PM
#29
g_force avatar

g_force

Zen Follower

Join Date:
Feb 2009
Posts:
354
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

OK this goes out to svenson as he seems one of the few to have mastered how to customise the product fields..

The site deals with downloadable items so I'm attempting to have a field for filesize on the advanced search.

I have followed your instructions in post #13 to the letter but I'm just getting a blank result screen.. -> here's what I did:

  1. added the following in /public_html/includes/templates/template_default/templates/tpl_advanced_search_default.php:
$products_filesize_arr = array(array('id' => '', 'text' => TEXT_NONE));

$products_filesize = $db->Execute("SELECT products_filesize from " . TABLE_PRODUCTS_DESCRIPTION . " GROUP BY products_filesize ORDER BY products_filesize");

while (!$products_filesize->EOF) {

$products_filesize_arr[] = array('id' => $products_filesize->fields['products_filesize'],

'text' => $products_filesize->fields['products_filesize']);

$products_filesize->MoveNext();

}
  1. then this in the same file:
<fieldset>
<legend>Filesize Heading</legend>
<?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_pull_down_menu('products_filesize', $products_filesize_arr, $pInfo->products_filesize); ?>
<br class="clearBoth" />
</fieldset>
  1. then I added the following in /public_html/includes/modules/pages/advanced_search/header_php.php:
  $sData['products_filesize'] = (isset($_GET['products_filesize']) ? zen_output_string($_GET['products_filesize']) : '');
  1. Now in /public_html/includes/modules/pages/advanced_search_result/header_php.php I added the following on around line 24:
(isset($_GET['products_filesize']) && !is_string($_GET['products_filesize'])) &&
  1. in the same file I added on line 60:
  if (isset($_GET['products_filesize'])) {
  
  $products_filesize = $_GET['products_filesize'];
  
  }

..this is just below:

  if (isset($_GET['keyword']) && $_GET['keyword'] != HEADER_SEARCH_DEFAULT_TEXT  && $_GET['keyword'] != KEYWORD_FORMAT_STRING) {
    $keywords = $_GET['keyword'];
  }
  1. then I included this:
'PRODUCTS_FILESIZE' => PRODUCTS_FILESIZE);

on line 153 (near the other similar statements).

  1. then I added this:
	case 'PRODUCTS_FILESIZE':
    $select_column_list .= 'pd.products_filesize';
    break;

.. around line 90 (below the others)

  1. then I have this around line 302:
		if (isset($_GET['products_filesize']) && zen_not_null($_GET['products_filesize'])) {
		
			$where_str .= " AND pd.products_filesize = :products_filesizeID";
			$where_str = $db->bindVars($where_str, ':products_filesizeID', $_GET['products_filesize'], 'string');
		}

..just below these statements:

    $where_str = $db->bindVars($where_str, ':categoriesID', $_GET['categories_id'], 'integer');
    $where_str = $db->bindVars($where_str, ':languagesID', $_SESSION['languages_id'], 'integer');
  }
}

Well that's the 8 steps I followed. Perhaps I have positioned something wrongly or there is a typo - I can't see it though. My suspicions are with step 8 of the process. The data stored is in varchar - don't know if this makes a difference to the variable types as you were contemplating in post #21 of this thread.

Anyway I hope that you can offer some guidance after your success >> it would be greatly appreciated.

_thanks

26 Oct 2009, 4:40 PM
#30
zvenson avatar

zvenson

New Zenner

Join Date:
May 2009
Posts:
61
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

Hi gforce!
thanks for the flowers and sorry for not answering earlier - just discovered your post - did you find a solution yet? Blank page sounds like php syntax error to me - haven't found the time to look into your code yet but will do it soon!

cheers!

www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

18 Jan 2010, 4:16 PM
#31
z3n avatar

z3n

Zen Follower

Join Date:
Apr 2008
Posts:
122
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

rajoo.sharma:

It may not be appropriate for everyone, but I think it can be very simple. Do not add any extra text boxes for custom fields for example products_author.

  1. includes/modules/pages/advanced_search_result/header_php.php

Find:
$where_str .= "(pd.products_name LIKE '%:keywords%'

After:

OR p.products_model
LIKE '%:keywords%'

Add:
OR p.products_author
LIKE '%:keywords%'

  1. includes/languages/your_template/advanced_search.php

Replace:

define('HEADING_SEARCH_CRITERIA', 'Choose Your Search Terms');

with:

define('HEADING_SEARCH_CRITERIA', 'Title, Author, ISBN/ISSN');

I have tried this, and other things, but can't get it to work. I added a field named "item_number" to my products table, and just want to make that searchable - I am running v1.3.8a

Thanks

19 Jan 2010, 8:00 AM
#32
rajoo_sharma avatar

rajoo_sharma

Zen Follower

Join Date:
Aug 2009
Posts:
137
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

z3n,

I have tried this, and other things, but can't get it to work.

I didn't get that, you meant you searched for a value stored in the field you added? and it didn't return that?

Since it is simple and should work without any problem, I'm not able to guess what went wrong.

Please zip all the files in which you made changes with a comment and attach them here, I'll check it at my end.

Rajeev Sharma

13 Apr 2010, 2:12 PM
#33
bikeforce avatar

bikeforce

New Zenner

Join Date:
Sep 2009
Posts:
73
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

I have managed to implement custom advanced search which search to and from (like price), I had to add some additions to th JS file also to stop the popup message causing an error....

My problem is I have alot of custom fields and I need to implement an if or case statement that will prevent all of my new fields showing up if they are not there(empty). I have customized the product listing page to do this, but the header_php (advanced search result page) file is set up differently.

in the product listing i have achieved it like this

case 'PRODUCT_LIST_D':
if ($listing->fields['products_D']=='0') {
//hide image column
$lc_text = '';
$lc_align = '';
$params= 'class="productListing-invis"';
} else {
$lc_text = '<div title="D (mm)">' . $listing->fields['products_D'] . '</div>';
$lc_align = 'right';
$params= 'class="productListing-heading"';
$zc_col_count_description++;}
break;

however it is stuctured completly differently in header_php

case 'PRODUCT_LIST_D':
$order_str .= "p.products_D";
break;

etc

Has anyone customized the advanced search result to do this? EG not show empty custom fields/columns.....

13 Apr 2010, 4:32 PM
#34
bikeforce avatar

bikeforce

New Zenner

Join Date:
Sep 2009
Posts:
73
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

What I think I need to do is use the php unset function to take out fields from the array if the result has no value....

Below i am trying to take out AP

  • Its not working

$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
'PRODUCT_LIST_THREAD_M' => PRODUCT_LIST_THREAD_M,
'PRODUCT_LIST_D' => PRODUCT_LIST_D,
'PRODUCT_LIST_L' => PRODUCT_LIST_L,
'PRODUCT_LIST_H' => PRODUCT_LIST_H,
'PRODUCT_LIST_AP' => PRODUCT_LIST_AP,
'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE);

if ($listing->fields['AP']=='0')

{
unset($define_list ['PRODUCT_LIST_AP']);
}

  • I think I need to change $listing->fields to something but dont know what - I know it is $product_info->fields on product info pages etc but dont know on this one. If there is a better way then, please let me know the solution...
2 May 2010, 9:27 AM
#35
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Advanced Search - customized product fields?

Has anyone managed to get this to work?

I have added a UPC, ASIN, PID, SKU & Even a Vendor SKU product field to my Products Info Page using custom fields.

Can see it here

My customers can search and get exact match for UPC, ASIN, PID, SKU and other hidden fields that I am testing to further categorize product without creating categories.

Is this what you are trying to do?

4 May 2010, 7:45 AM
#36
bikeforce avatar

bikeforce

New Zenner

Join Date:
Sep 2009
Posts:
73
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

I dont know if your question was addressed at me but I still would like any ideas regarding my situation.

I have successfully customized advanced search

http://www.fastenerforce.co.uk/

however the results page runs from the product listing template - which should display css-column collapse - it does in the product listing but the advanced search list columns arent registering it and displaying empty columns which is clunky......

2 Jun 2010, 9:01 AM
#37
mick_walmsley avatar

mick_walmsley

New Zenner

Join Date:
Oct 2008
Posts:
1
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

Hi

I am also trying to amend the search function. I am working on a site that sells tyres. Tyres have certain characteristics that are used when searching for the tyres for your vehicle:
Width
Profile
Wheel Size
Load Index
Speed Rating

I have created a new table PRODUCTS_TYRES with products_id as the key and then products_width, products_profile, products_wheel_size, products_load_index, products_speed_rating as fields within the table.

I do not want to search on any of the traditional search variables as these are not required.

I believe that I have created the correct result array and that the array is sorted alphabetically. I have created the SELECT, FROM and WHERE strings.

However when I try the page, using just the width search term (I will add the code for the other fields once I know that is working correctly) I get an error message that "At least one of the fields in the search form must be entered".

Here is the page:
http://www.tyrexchange.co.uk/index.php?main_page=advanced_search

Has anybody got any ideas that may help me as I have been scratching my head on this for two days now?

Thanks in advance

Mike

2 Jun 2010, 9:11 AM
#38
bikeforce avatar

bikeforce

New Zenner

Join Date:
Sep 2009
Posts:
73
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

I had this problem, cant remember but think you add your fields at the top eg.

(isset($_GET['s_dfrom']) && !is_numeric($_GET['s_dfrom'])) &&
(isset($_GET['s_dto']) && !is_numeric($_GET['s_dto']))&&

think you add your code at the top. You could delete the message stack or add your own custom ones eg...

if (($L_D_check_error == false) && is_numeric($L_dto) && is_numeric($L_dfrom)) {
if ($L_dfrom >= $L_dto) {
$error = true;

  $messageStack->add_session('search', " L (mm) From value should be less than L (mm) To value");
}

}

20 Jun 2010, 9:51 AM
#39
steveyork136 avatar

steveyork136

New Zenner

Join Date:
Nov 2005
Posts:
84
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

help!:wacko:

I've followed zvenson code from earlier in this thread but it doesn't seem to be working for me.
The biggest issue seems to be the extra table I have isn't be included in the sql query (I'm echoing it to the page for testing).

I have an extra table with a product_id which matches products table id's, each record has an extra field called p_added_make which is what I'm searching against.

USING(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c )
LEFT JOIN " . TABLE_ADDED_FIELDS. " pu
ON pu.products_id= p2c.products_id

LEFT JOIN " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd
ON mtpd.products_id= p2c.products_id
AND mtpd.language_id = :languagesID";

on the site the extra table is not appearing in the query.

USING(manufacturers_id), z_table_products_description pd, z_table_categories c, z_table_products_to_categories p2c ) LEFT JOIN z_table_meta_tags_products_description mtpd ON mtpd.products_id= p2c.products_id AND mtpd.language_id = 1

the table prefix is correct (TABLE_ADDED_FIELDS) but am I missing something else.

Should there be something in the SELECT DISTINCT part of the query?

1 Sep 2010, 11:50 AM
#40
impalor avatar

impalor

New Zenner

Join Date:
Jul 2009
Posts:
2
Plugin Contributions:
0

Re: Advanced Search - customized product fields?

Bikeforce:

I dont know if your question was addressed at me but I still would like any ideas regarding my situation.

I have successfully customized advanced search

http://www.fastenerforce.co.uk/

however the results page runs from the product listing template - which should display css-column collapse - it does in the product listing but the advanced search list columns arent registering it and displaying empty columns which is clunky......
Hy, indeed youhave customized advanced search.Can you share with us how this is done?
Thank you!:clap: