Page 1 of 2 12 LastLast
Results 1 to 10 of 52

Hybrid View

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

    Default Advanced Search - customized product fields?

    Hey Community!
    I am trying do expand the advanced search feature so that it is capable of searching custom fields and tables i added to the database. I created some extra database tables that hold extra information about products by using this how to:
    http://www.zen-cart.com/forum/showthread.php?t=120523

    now i have - let`s say - one field called "class_of_absorbtion" in a table called "products_extra_stuff" and of course a products_id field in that same table so the extra information can be allocated easily to the product.

    I figured out how to insert the field in the search tpl by editing:

    /includes/templates/my_template/templates/tpl_advanced_search_default.php

    i added this code to /tpl_advanced_search_default.php to generate a dropdown with the options from the database:

    <?php
    $absorbtion_array = array(array('id' => '', 'text' => TEXT_NONE));

    $abso = $db->Execute("select id, absorbtionclass from " . TABLE_ABSO . " order by id");

    while (!$abso->EOF) {

    $absorbtion_array[] = array('id' => $abso->fields['absorbtionclass'],

    'text' => $abso->fields['absorbtionclass']);

    $abso->MoveNext();

    }
    ?>
    and this where the form and the dropdown is created
    <fieldset>
    <legend>Class of absorbtion</legend>
    <?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_pull_down_menu('class_of_absorbtion', $absorbtion_array, $pInfo->class_of_absorbtion); ?>
    <br class="clearBoth" />
    </fieldset>
    now i modified the
    /include/modules/pages/advanced_search/header_php.php and added this code so the value of the input is processed in the search:
    $sData['class_of_absorbtion'] = (isset($_GET['class_of_absorbtion']) ? zen_output_string($_GET['class_of_absorbtion']) : '');
    next step would be to modify the
    /include/modules/pages/advanced_search_results/header_php.php

    this is where the actual search is done, right?

    Now i`m stuck on how to edit the search query because i don`t know where to tell zen cart that it should also pick results where the "class_of_absorbtion" value from the products_extra_stuff table concurs in the value of the search query.

    Any suggestion and hints would be highly appreciated!

    Thank you very much!
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

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

    Default Re: Advanced Search - customized product fields

    well somehow i figured it out but get a strange error...

    the search can be expanded to custom tables by adding this to your
    /include/modules/pages/advanced_search_results/header_php.php

    - assuming you have a field called extras_flammability_test
    if (isset($_GET['extras_flammability_test'])) {

    $extras_flammability_test = $_GET['extras_flammability_test'];

    }
    then in the $define_list = array
    i added something like
    'PRODUCT_EXTRAS_FLAMMABILITY_TEST' => PRODUCT_EXTRAS_FLAMMABILITY_TEST,
    in the query i added
    LEFT JOIN " . TABLE_PRODUCTS_EXTRA_STUFF. " pu

    ON pu.products_id= p2c.products_id
    and did some other minor changes to the file. 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 - i m looking at it for quite a time now but cannot find out what went wrong - has anyone a hint or point my stupid face to it so i can find the problem? thank you -
    the advanced search can be found here
    (the page is under developement right now and there are only test products included but for testing purposes it should be okay)

    thanks for help!
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

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

    Default Re: Advanced Search - customized product fields

    okay found the problem - often it just helps to write it down and ask in the forums and then give the answer to it myself
    if anyone is interested in the solution let me know
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Advanced Search - customized product fields

    It is always helpful if you post the solution to any problem, even if you do work it out for yourself, so that others can be helped by your discoveries ...
    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!

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

    Default Re: Advanced Search - customized product fields?

    yeah - that`s what i want to do but ran into antother problem

    i want to select a value "class_of_absorbtion" which can be in three different tables (for each product). This value can be in one, two or three or neither of the tables. I have and sql statement like this:

    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 p.products_id = pu.products_id AND p.products_id = pac.products_id AND p.products_id = puc.products_id AND p.products_id = pic.products_id AND p2c.categories_id = c.categories_id AND (pac.class_of_absorbtion OR puc.class_of_absorbtion_second OR pic.class_of_absorbtion_third) ='B'
    so there are three tables of class_of_absorbtion. Im confused about the OR and AND statement - my code doesn`t work so maybe i have again something wrong in my php or even in my logic.
    If anyone could have a quick look at this would be very nice!
    thank you!
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

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

    Default Re: Advanced Search - customized product fields?

    no one helping? what a bummer....
    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?

    Sorry Zvenson,

    you are right. That's the situation in advanced search:

    - if I leave the search field "keywords" blank and i fill only the new search field with an author name (it is supposed to search in my new field "author"), zen cart tell me "You must fill at least one field of research"

    - if i fill "keywords" with a word and the new field with an author name, zencart gives me back only the products that match the first criteria

    So, Zenky seems to ignore my second search field...

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

    Default Re: Advanced Search - customized product fields?

    Hi Marco!
    Well, my first thought is, that there must be something wrong in this line where you put this:
    && empty($products_author)
    this line should check if the author (or any other field) is empty and if so - you get the error message that nothing has been entered. Well - the reason for this could be, that the "$products_author" variable is empty - try inserting an
    Code:
    echo $products_author;
    above the line where all the "&& emptys" are - then enter a search word in the products author field - do a search and look if the $produts_author is "echoed" (printed) somewhere on your screen. if it is not - then there must be something wrong bevor the actuall search is done...
    Hope this again helps a little!
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  9. #9
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: Advanced Search - customized product fields?

    I'm now following this thread for my own reasons! I have added a new table of product details (e) instead of adding to the product table. All of possible search fields are boolean - either 1 or 0 which is served by checkboxes on the search form.

    So looking at your code suggestion above,
    1) (isset($_GET['dwarf']) && !is_numeric($_GET['dwarf'])) &&
    2) && empty($dwarf)
    3) case 'dwarf':
    $select_column_list .= 'e.dwarf';
    4) if (isset($_GET['dwarf']) && zen_not_null($_GET['dwarf'])) {
    $where_str .= " AND e.dwarf = :dwarf";
    $where_str = $db->bindVars($where_str, ':dwarf', $_GET['dwarf'], 'string');
    }

    this doesn't work - and I know the field isn't a string as in number 4.

    When I say it doesn't work - the search page just refreshed itself and never goes to the results page.

    I'm pretty sure I've got the table added correctly to the select statement and even if I didn't, I'm not getting that far!

    What might be wrong?
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  10. #10
    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:	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.
    Last edited by bb21; 29 Jan 2013 at 01:44 PM. Reason: Modified sentence

 

 
Page 1 of 2 12 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

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