Page 1 of 6 123 ... LastLast
Results 1 to 10 of 52
  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: v1.5.5]
    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
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Hi!
    I`m really stuck over here so if anyone could help me that would be sooooooooo nice...
    I'm trying to explain my problem again:

    I have 3 Tables called:
    products_acoustics
    products_acoustics_second
    products_acoustics_third

    each table contains a field products_id and a field for the acoustics information which can be values from A to E.
    the three fields for the acoustics information are called
    class_of_absorbtion (for table products_acoustics)
    class_of_absorbtion_second (for table products_acoustics_second)
    class_of_absorbtion_third (for table products_acoustics_third)

    so i think i need to "left join" these tables together so i can get the coresponding product with just one "where" clause, right?

    I tried the following (from clause)
    $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_PRODUCTS_EXTRA_STUFF. " pu

    ON pu.products_id= p2c.products_id


    LEFT JOIN " . TABLE_PRODUCTS_ACOUSTICS. " pac
    ON pac.products_id = p2c.products_id
    LEFT JOIN " . TABLE_PRODUCTS_ACOUSTICS_SECOND. " puc
    ON pac.products_id = puc.products_id
    LEFT JOIN " . TABLE_PRODUCTS_ACOUSTICS_THIRD. " pic
    ON pac.products_id = pic.products_id


    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');
    and here the where clause
    if (isset($_GET['class_of_absorbtion']) && zen_not_null($_GET['class_of_absorbtion'])) {

    $where_str .= " AND (pac.class_of_absorbtion
    OR puc.class_of_absorbtion_second
    OR pic.class_of_absorbtion_third) = :absoID";
    $where_str = $db->bindVars($where_str, ':absoID', $_GET['class_of_absorbtion'], 'string');


    }
    I know i must have gotten something wrong, because still only the first table "class_of_absorbtion" and the field "class_of_absorbtion" is searched. If anyone could help me a little on this, would be sooo nice. Hope anyone does. Thank you!
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

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

    Default Re: Advanced Search - customized product fields?

    well now i solved it - was just a tiny little thing, but if no one helps these things are sometimes hard to find

    here`s the code for the correct where clause

    Code:
     $where_str .= " AND (pac.class_of_absorbtion=:absoID
     OR puc.class_of_absorbtion_second=:absoID
    OR pic.class_of_absorbtion_third=:absoID)";
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

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

    Default Re: Advanced Search - customized product fields?

    Thanks for posting the update to the coding syntax error ...
    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: v1.5.5]
    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!

  10. #10
    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

 

 
Page 1 of 6 123 ... 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