Page 5 of 6 FirstFirst ... 3456 LastLast
Results 41 to 50 of 52
  1. #41
    Join Date
    Jan 2004
    Posts
    482
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Very cool. Did you post instructions anywhere?

    Quote Originally Posted by impalor View Post
    Hy, indeed youhave customized advanced search.Can you share with us how this is done?
    Thank you!

  2. #42
    Join Date
    Sep 2004
    Posts
    173
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    How difficult would it be to to change MANUFACTURERS to RECORD COMPANIES?

    I don't use manufacturers, I use Distributors - which is actually an english renaming of Record Companies field. So in effect,
    I would change the language to "Limit To Distributors" but would need the record companies in the drop down.

    (I have to do it this way because I have music products, and that is the layout in the add product entries)

    Thanks in advance.
    Vin

  3. #43
    Join Date
    Feb 2011
    Posts
    4
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product attribute fields

    Zen Cart 1.3.8a
    Site was updated from 1.3.7 back in 2008

    I am not sure of any add-ins as I am the new webmaster for this site. I'm also new to Zen Cart. My background in php and mysql so learning a new tool is not very difficult.

    My client has requested a change to the Advanced Search to allow customer to search past orders on a product attribute. I have followed the recommendations of this post and have modified 4 files to implement this change. I think I just need a few more tweaks, but am stuck.

    Here are the changes I have made:

    1. modified the file
    \my_template\includes\templates\my_template\templates\tpl_advanced_search_defaul t.php by adding a new fieldset

    Code:
    <fieldset>
    <legend>OR Search Past Orders by Patient Name</legend>
     <div class="centeredContent"><?php echo zen_draw_input_field('patient', $sData['patient'], 'onfocus="RemoveFormatString(this, \'' . PATIENT_FORMAT_STRING . '\')"'); ?>&nbsp;&nbsp;&nbsp;<?php echo zen_draw_checkbox_field('search_in_patient', '1', $sData['search_in_patient'], 'id="search-in-patient"'); ?><label class="checkboxLabel" for="search-in-patient"><?php echo TEXT_SEARCH_IN_PATIENT; ?></label></div>
    
    <br class="clearBoth" />
    </fieldset>
    2. modified the file my_template\includes\modules\pages\advanced_search\header_php.php to define the $sData field

    Code:
      $sData['patient'] =  (isset($_GET['patient']) ? zen_output_string($_GET['patient']) : zen_output_string(PATIENT_FORMAT_STRING));
    
      $sData['search_in_patient'] = (isset($_GET['search_in_patient']) ? zen_output_string($_GET['search_in_patient']) : 1);

    3. modified the file my_template\includes\languages\english\advanced_search.php

    Code:
    define('TEXT_SEARCH_IN_PATIENT', 'Search In Order for Patient Attribute');
      define('PATIENT_FORMAT_STRING', 'patient');
    4. modified the file my_template\includes\modules\pages\advanced_search_result\header_php.php to adjust the from and where clause code. I'm only allowing them to search either by product description OR by past order product attritbute 'Patient. So this was a big code change to this file. I'm sure I haven't done it correctly and not gettting any result.

    I will break the code down into places that I modified as this page has many lines.

    1. added get my variable like the keyword search does.
    Code:
    $_GET['keyword'] = trim($_GET['keyword']);
    
    $_GET['patient'] = trim($_GET['patient']);
    2. Added the new patient variable to the test if any search criteria was entered so I don't get the error message.

    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'])) &&
    
    (isset($_GET['patient]) && (empty($_GET['patient'])) ) {
    3. added variable to hold the contents of the new fiield on the page.

    Code:
     if (isset($_GET['patient'])) {
    
        $patients = $_GET['patient'];
    
      }

    4. Since my search needs to be on the orders_products_attributes table and having to link other tables to search by customer, I had to change the entire "from str" . So I'm creating my own From string.


    Code:
    if (isset($_GET['patient'])) {
    
      $from_str = "FROM  " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " pat,
                         " . TABLE_ORDERS_PRODUCTS . " op,
                         " . TABLE_ORDERS . " o,
    					 " . TABLE_PRODUCTS . " p,
    					 " . TABLE_PRODUCTS_DESCRIPTION . " pd";
    
    		 
    
    
      }
     else
     {
    $from_str = "FROM (" . TABLE_PRODUCTS . " p
    
                 LEFT JOIN " . TABLE_MANUFACTURERS . " m
    
                 USING(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c )
    
                 LEFT JOIN " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd
    
                 ON mtpd.products_id= p2c.products_id
    
                 AND mtpd.language_id = :languagesID";
    
    
    }
    $from_str = $db->bindVars($from_str, ':languagesID', $_SESSION['languages_id'], 'integer');
    the else statement was added to use the original From_str if they don't search by patient.

    5. Same for the Where String since I have different tables to join.

    Code:
    if (isset($_GET['patient'])) {
    $where_str = " WHERE (p.products_status = 1
                   AND p.products_id = pd.products_id
                   AND pat.orders_id = o.orders_id
    			   AND op.orders_id = o.orders_id
    			   AND op.products_id = p.products_id
    			   AND pat.products_options = 'Patient'
                   AND pd.language_id = :languagesID
    			   AND o.customers_id = :customerID
    			   AND pat.products_options_values LIKE '%:patient%'";
    			   
    $where_str = $db->bindVars($where_str, ':customerID', $_SESSION['customers_id'], 'integer');
    
    }
    else
    {
    $where_str = " WHERE (p.products_status = 1
    
                   AND p.products_id = pd.products_id
    
                   AND pd.language_id = :languagesID
    
                   AND p.products_id = p2c.products_id
    
                   AND p2c.categories_id = c.categories_id ";
    
    
    }
    $where_str = $db->bindVars($where_str, ':languagesID', $_SESSION['languages_id'], 'integer');

    6. I didn't change the Select or Sort order string because I want the same fields selected for display and assume it will continue sorting by product name. That is why I joined the Products_Description table.

    So my question is now that I have my SQL statement constructed with the from, where and sort which I assume happens in this line

    Code:
    $listing_sql = $select_str . $from_str . $where_str . $order_str;
    how does it call the database and execute the search. Here is the remaining code in this page, but not sure what it is calling.

    Code:
    $zco_notifier->notify('NOTIFY_SEARCH_ORDERBY_STRING', $listing_sql);
    
    $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ADVANCED_SEARCH));
    
    $breadcrumb->add(NAVBAR_TITLE_2);
    
    
    
    
    
    $result = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
    
    if ($result->number_of_rows == 0) {
    
      $messageStack->add_session('search', TEXT_NO_PRODUCTS, 'caution');
    
      zen_redirect(zen_href_link(FILENAME_ADVANCED_SEARCH, zen_get_all_get_params('action')));
    
    }
    
    
    
    // This should be last line of the script:
    
    $zco_notifier->notify('NOTIFY_HEADER_END_ADVANCED_SEARCH_RESULTS', $keywords);

    As I said I'm a newbie to Zen Cart. It is hard to follow at times, but I was able to figure out where to change the code, just need a little push to get it working.

    Thanks,
    Marnie

  4. #44
    Join Date
    Feb 2011
    Posts
    4
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    ANother thing to add to my post above. I noticed when I click on search the url address that it builds still contains the other two search fields.

    I don't understand what the x=24&y=3 means.
    Last edited by marnieg; 9 Mar 2011 at 05:28 PM. Reason: the url was not being fully displayed added the URL tag

  5. #45
    Join Date
    Aug 2011
    Posts
    21
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    hello again,

    I need help. I managed to create a search box that searches the right column (extra fields in products table). It works

    but ...

    if I have two search boxes like this it is capable to process the search of one...and not the other (it says that there are no products matching the criteria...but in reality there are...) or BOTH at the same time (that works no problem).
    if I add one more it either searches one or all the columns at the same time. what should I do to make it search by field 1, 2 or three or any other combination of the three?

    actually, if you just click in the search box and leave it black it will do the search correctly. what did I miss? it seems like that it takes either PRODUCTS_COLOR_FORMAT_STRING or any other xx_format_string as the search value. (if you click on the advanced search in my shop..I left there only one search box - by color). but the remove string should work??

    this is my template file...or at least the relevant part

    PHP Code:
    <fieldset>
    <legend><?php echo HEADING_SEARCH_CRITERIA?></legend>
    <div class="forward"><?php echo '<a href="javascript:popupWindow(\'' zen_href_link(FILENAME_POPUP_SEARCH_HELP) . '\')">' TEXT_SEARCH_HELP_LINK '</a>'?></div>
    <br class="clearBoth" />

        <div class="centeredContent"><?php echo zen_draw_input_field('keyword'$sData['keyword'], 'onfocus="RemoveFormatString(this, \'' KEYWORD_FORMAT_STRING '\')"'); ?>&nbsp;&nbsp;&nbsp;<?php echo zen_draw_checkbox_field('search_in_description''1'$sData['search_in_description'], 'id="search-in-description"'); ?><label class="checkboxLabel" for="search-in-description"><?php echo TEXT_SEARCH_IN_DESCRIPTION?></label></div>
     
    <br class="clearBoth" />
    </fieldset>

    <!-- search by color --> 
    <fieldset class="floatingBox back">    
    <legend>Vyhledávání podle barvy</legend>
    <br class="clearBoth" />

     <?php echo zen_draw_input_field('products_color'$sData['products_color'], 'onfocus="RemoveFormatString(this, 

    \'' 
    PRODUCTS_COLOR_FORMAT_STRING '\')"'); ?>

    </fieldset>
        <!-- konec search by color -->

    </P>
    and these are the changes in the headers
    PHP Code:
    if  [blabla] (isset($_GET['products_color']) && !is_string($_GET['products_typemtg'])) &&  [...]
     
     
    } else {
      
    $products_color '';

    if (isset(
    $_GET['products_color'])) {
        
    $products_color$_GET['products_color'];
      } 

    PHP Code:
    if (empty($dfrom) && empty($products_edition) && empty($products_typemtg) && empty($products_rarity) && empty($products_color) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {
      
    $error true
    PHP Code:
    switch ($column_list[$col]) {
      [..]
      case 
    'PRODUCTS_COLOR':
        
    $select_column_list .= 'p.products_color';
        break; 
    [...] 
    PHP Code:
    if (isset($_GET['products_color']) && zen_not_null($_GET['products_color'])) {
      
    $where_str .= " AND p.products_color = :products_colorID";
      
    $where_str $db->bindVars($where_str':products_colorID'$_GET['products_color'], 'string');

    etc...
    the shop I'm working on now...
    http://outcast.cz/

  6. #46
    Join Date
    Aug 2011
    Posts
    21
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    it does not seem that I can edit the previous post.

    my shop is located at outcast.cz

    in the end I would need a search engine that uses checkboxes. so the customer could filter the products by color, rarity, type etc. but for the time being I'm trying to get this to work. It would work if not for removing the initial string from the box....
    the shop I'm working on now...
    http://outcast.cz/

  7. #47
    Join Date
    Jul 2011
    Posts
    27
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Ok I got this working but the downside is only works with one extra search field not sure why working on this problem now on local server but the live server is running.

    www.jazmin-books.co.uk


    This is all linking to a extra table created products_extra_stuff.

    pages/advanced_search/header_php

    at the end add

    $products_author = (isset($_GET['products_author']) ? zen_output_string($_GET['products_author']) : '');


    pages/advanced_search_result/header_php

    Line 27 ish

    (isset($_GET['products_author']) && (empty($_GET['products_author']))) &&

    Line 56 ish

    if (isset($_GET['products_author'])) {
    $products_author = $_GET['products_author'];
    }
    Line 132 ish

    && empty($products_author)
    Line 189 ish

    case 'PRODUCTS_AUTHOR':
    $select_column_list .= 'p.products_author';
    break;

    Line 236 ish

    LEFT JOIN " . TABLE_PRODUCTS_EXTRA_STUFF. " pu
    ON pu.products_id= p2c.products_id
    line 276 ish

    if (isset($_GET['products_author']) && zen_not_null($_GET['products_author'])) {
    $where_str .= " AND products_author = : products_author";
    $where_str = $db->bindVars($where_str, ': products_author', $_GET['products_author'], 'string');
    }
    templates/YOUR TEMPLATE/

    <fieldset>
    <legend>Search by Author</legend>
    <div class="centeredContent"><?php echo zen_draw_input_field('products_author', $sData['products_author'], 'onfocus="RemoveFormatString(this, \'' . KEYWORD_FORMAT_STRING . '\')"'); ?>
    <br class="clearBoth" />
    </fieldset>

    Don`t for get to add your database table to the list of database.

    hope this helps people out

    p.s. this is working on a server with 562911 products
    Last edited by klevans; 25 Oct 2011 at 02:52 PM.

  8. #48
    Join Date
    Jul 2011
    Posts
    27
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Cool fixed it.

    pages/advanced_search_result/header_php


    On this line you will have.

    if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {
    most people will have added there extra emptys ie

    if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($products_author) && empty($products_publisher) && empty($products_isbn13) && empty($keywords)) {
    This is wrong you need to have it like this.

    if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {
    } else if (empty($products_author) && empty($products_publisher) && empty($products_isbn13)){


    Now you can have multiple search fields that can be empty.


    Hope this helps you all.

  9. #49
    Join Date
    Aug 2011
    Posts
    21
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    klevans: doing exactly what you did results in zencart telling me that at least on of the search conditions has to be filled in.

    i don't know what to do. if I remove the keyword_format_string from the search box it does the search. but otherwise it will take the translated keyword_format_string as a value.

    I have to be overlooking something somewhere...anyone had the same problem?
    the shop I'm working on now...
    http://outcast.cz/

  10. #50
    Join Date
    Jan 2013
    Posts
    1
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields

    Hi Zvenson,

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

    Quote Originally Posted by zvenson View Post
    The search performs and gets the products where the criteria are matching, but somehow on every result i get there are 4 buttons to add the product to the shopping cart

    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:	106 
Size:	8.7 KB 
ID:	11857

    Click image for larger version. 

Name:	2013-01-29_201811.gif 
Views:	97 
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.
    Last edited by bb21; 29 Jan 2013 at 01:44 PM. Reason: Modified sentence

 

 
Page 5 of 6 FirstFirst ... 3456 LastLast

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

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR