Page 2 of 2 FirstFirst 12
Results 11 to 20 of 52

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    7
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields

    I've just finished making my advanced search work with all sorts of custom fields and I thought this small piece of info may help someone who is having trouble with the empty keywords on search:

    You dont need to check for an empty anything (there is even a comment stating the check can safely be removed), I started putting all sort of checks for empty against my various fields, but actually if you just remove all the checks and search on nothing it just returns all products... which I think is just fine. Obviously you will still need to apply format checks.

    So there are two places you need to look for these checks:
    There is a client side (js) check in includes/modules/pages/advanced_search/jscript_main.php:

    Code:
    //if ( ((keyword == '') || (keyword.length < 1)) && ((dfrom == '') || (dfrom == '<?php echo DOB_FORMAT_STRING; ?>') || (dfrom.length < 1)) && ((dto == '') || (dto == '<?php echo DOB_FORMAT_STRING; ?>') || (dto.length < 1)) && ((pfrom == '') || (pfrom.length < 1)) && ((pto == '') || (pto.length < 1)) ) {
      //  error_message = error_message + "* <?php// echo ERROR_AT_LEAST_ONE_INPUT; ?>\n";
      //  error_field = document.advanced_search.keyword;
      //  error_found = true;
      //}
    as you can see all commented out.

    Then there is a server side check in includes/modules/pages/advanced_search_result/header_php.php:

    Code:
    /*
    if ( (isset($_GET['keyword']) && (empty($_GET['keyword']) || $_GET['keyword']==HEADER_SEARCH_DEFAULT_TEXT || $_GET['keyword'] == KEYWORD_FORMAT_STRING ) ) &&
    (isset($_GET['dfrom']) && (empty($_GET['dfrom']) || ($_GET['dfrom'] == DOB_FORMAT_STRING))) &&
    (isset($_GET['dto']) && (empty($_GET['dto']) || ($_GET['dto'] == DOB_FORMAT_STRING))) &&
    (isset($_GET['pfrom']) && !is_numeric($_GET['pfrom'])) &&
    (isset($_GET['pto']) && !is_numeric($_GET['pto']))) {
      $error = true;
      $missing_one_input = true;
      $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
    } else {
     * 
     */
    also need to comment out the close to that else statement;

    Another thing that I found was it was quite easy to integrate the dynamic filter plugin with the advance search form - this plugin already allows you to search on any attributes you have. You will need to take out price and category options from here to avoid conflicts with the advanced search.
    Last edited by WebweaverD; 10 Feb 2013 at 08:32 PM.

  2. #2
    Join Date
    May 2014
    Location
    Sheffield
    Posts
    1
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields

    Quote Originally Posted by bb21 View Post
    Hi Zvenson,

    May I ask how did you resolve the following problem? Mine has 2 buttons on every product result.




    My custom advanced search changes are still on my Local PC so I won't be able to share you a link. But I am providing screenshots of the search result for your reference.

    Click image for larger version. 

Name:	2013-01-29_203424.gif 
Views:	118 
Size:	8.7 KB 
ID:	11857

    Click image for larger version. 

Name:	2013-01-29_201811.gif 
Views:	103 
Size:	9.3 KB 
ID:	11856


    Zen Cart version: 1.5.1

    Modified files (all changes I made came from this thread):
    \includes\templates\template_default\templates\tpl_advanced_search_default.php
    \includes\modules\pages\advanced_search\header_php.php
    \includes\modules\pages\advanced_search_result\header_php.php

    I am using 1 extra table so in the LEFT JOIN part, I only added this:

    Code:
    LEFT JOIN " . TABLE_PRODUCT_EXTRA_FIELDS . " pe
                 ON pe.products_id= p2c.products_id

    @All, appreciate your feedback as well. Thank you.
    Hi,

    I have got the advanced search results working fine, all except I have 4 prices and cart showing on each product result, May I ask how did you resolve the problem of having 2 buttons on every product result.? I have looked through the threads but can not see any mention of a fix.

    Using 1.5.1

    Thank you in advance.

  3. #3
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    help question Re: Advanced Search - customized product fields?

    Hi Ajeh and Zvenson,

    I'm having some similar problem with advanced search.

    I've added a field called "products_author" in "products" table, and now I'm trying to edit the advanced search adding the research also in this new field.

    Until now I have no result, I've looked for tutorials or hints on the web, but I can't find... can u give me some help, please?

    Thank u very much,
    Marco

  4. #4
    Join Date
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    sure - what did you do til now?
    The main two files to edit are theses two
    /include/modules/pages/advanced_search_results/header_php.php
    /include/modules/pages/advanced_search/header_php.php

    and of course the template for the search site...

    i think in this thread there is all the information you need, but not nicely structured - so if you post your changes to the 2 files above i`ll have a look at it!
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  5. #5
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    xhtml problem Re: Advanced Search - customized product fields?

    Hi Zvenson,

    Thanks for the quick answer.

    Actually I'm stucked, I understand that the answer I was looking for is in this thread but I can't extract it (as you said, you write during the process, so is not linear). Consider also that usually I work with xhtml, css and wordpress, so I'm not good in php.

    Your case is different from mine because you have to search in new tables with new fields, while in my case I've to search in a new field (products_author) of an existing table (products).

    It's not yet useful sending u my code because after some wrong attempts I bring back the code to the original.

    If you have the time and the patience to show me how to procede, I'll be very grateful.

  6. #6
    Join Date
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    I can't extract it (as you said, you write during the process, so is not linear).
    - sorry for that - but unfortunately this forum only allows edits 7 minutes after posting :) - and it`s not a tutorial ...


    while in my case I've to search in a new field (products_author) of an existing table (products).
    Is this just a simple text input field where you type in some name and it looks this up in the database?


    First you have to add a field to the advanced search form. Edit:

    /includes/templates/YOUR-TEMPLATE/templates/tpl_advanced_search_default.php file

    and add something like this:
    Code:
      <div class="centeredContent"><?php echo zen_draw_input_field('YOUR_NEW_FIELD', $sData['your_new_field'], 'onfocus="RemoveFormatString(this, \'' . KEYWORD_FORMAT_STRING . '\')"'); ?>
    where you want the new field to appear in the search form.

    Then edit the
    /include/modules/pages/advanced_search/header_php.php

    to "GET" the data from the field by adding something like this:
    Code:
      $your_new_field =      (isset($_GET['your_new_field'])   ? zen_output_string($_GET['your_new_field']) : '');
    now you just (okay, this is the tricky part) need to tell zen-cart to search the new data when something is submitted:
    edit:
    /include/modules/pages/advanced_search_results/header_php.php
    Code:
    (look for similar looking lines to paste this somewhere in between)
    (isset($_GET['your_new_field']) && !is_string($_GET['your_new_field'])) &&
    
    (same thing here: look for similar lines and just paste:
      if (isset($_GET['your_new_field'])) {
        $your_new_field = $_GET['your_new_field'];
      }
    
    (now search for "if (empty($dfrom)" and add somewhere between the &&empty something like this:)
    && empty($your_new_field)
    
    (search for similar and past:)
    case 'YOUR_NEW_FIELD':
        $select_column_list .= 'p.your_fieldname_in_db';
        break;
    
    (search for similar lines and paste:)
    if (isset($_GET['your_new_field']) && zen_not_null($_GET['your_new_field'])) {
      $where_str .= " AND p.your_new_fielname_inDB = :yourfieldnameID";
      $where_str = $db->bindVars($where_str, ':yourfieldnameID', $_GET['your_field_name'], 'string');
    }
    of course you have to change your_field_name to the variable you want to search and change your_new_fildname_inDB as well.


    well this should be it - but i`m totally not sure - im the trial and error kind as well :) just try it and tell me when you succeed - hope it helps somehow...
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  7. #7
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Thanks for the detailed answer!
    I've done the process but it doesn't work yet...

    /tpl_advanced_search_default.php file

    1) Ok, I've added:
    Code:
    <div class="centeredContent"><?php echo zen_draw_input_field('PRODUCTS_AUTHOR', $sData['products_author'], 'onfocus="RemoveFormatString(this, \'' . KEYWORD_FORMAT_STRING . '\')"'); ?>

    /include/modules/pages/advanced_search/header_php.php

    2) Ok, I've added:
    Code:
     $sData['products_author'] = (isset($_GET['products_author'])   ? zen_output_string($_GET['products_author']) : '');

    /include/modules/pages/advanced_search_results/header_php.php

    3) added:
    Code:
    (isset($_GET['products_author']) && !is_string($_GET['products_author'])) &&
    4) added
    Code:
    if (isset($_GET['products_author'])) {
        $your_new_field = $_GET['products_author'];
      }
    5) added
    Code:
    && empty($products_author)
    6) added
    Code:
    case 'PRODUCT_LIST_AUTHOR':
        $select_column_list .= 'p.products_author';
        break;
    7) added, but I'm not sure about the ID part...
    Code:
    if (isset($_GET['products_author']) && zen_not_null($_GET['products_author'])) {
      $where_str .= " AND p.products_author = :productsauthorID";
      $where_str = $db->bindVars($where_str, ':productsauthorID', $_GET['products_author'], 'string');
    }
    Where I'm wrong?

  8. #8
    Join Date
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    would be nice if you would tell us what happens when you start the search. This would make things much easier - maybe you can .provide a link
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  9. #9
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Actually I'm testing locally, I haven't put it on the web yet. As soon as I put it I'll tell you.

    Thanks,
    Marco

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v139h Custom Advanced Search Fields
    By divinelighting in forum General Questions
    Replies: 0
    Last Post: 27 Jul 2012, 08:22 PM
  2. Modify Advanced Search Fields
    By JimRoster in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 9 Oct 2011, 07:41 AM
  3. Modifying the Advanced Search Form Fields?
    By uruharacosplay in forum General Questions
    Replies: 0
    Last Post: 4 Mar 2008, 06:43 PM
  4. Modify Advanced Search Fields
    By icebox500 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 9 Aug 2007, 10:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg