Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2010
    Posts
    20
    Plugin Contributions
    0

    Default How do I change the search feature to look through custom product-type fields?

    How do I change the search feature to look through custom product attributes?

    For example: the music type custom product type included with ZC has an attribute "Recording Artist" and a value "System of a Down." If I type "System of a down" in the search bar on my homepage, this custom product won't show up.

    I'd guess it is because the search feature needs to be modified to include these custom attributes. What files do I need to modify/overwrite to get the search to look through the custom attributes?

    Thanks ZC crew!

  2. #2
    Join Date
    Apr 2010
    Posts
    20
    Plugin Contributions
    0

    help question Re: Adding New Product_types

    My mistake, I can search for artist but I can not search for the "Record Company."

    Thanks

  3. #3
    Join Date
    Apr 2010
    Posts
    20
    Plugin Contributions
    0

    Default Re: How do I change the search feature to look through custom product-type fields?

    Hey ZC crew.

    There is a thread that answers my question I think: http://www.zen-cart.com/forum/showthread.php?p=517239

    I'll post more details if I think it could help others when I figure it out for myself

  4. #4
    Join Date
    Apr 2010
    Posts
    20
    Plugin Contributions
    0

    Default Re: How do I change the search feature to look through custom product-type fields?

    Hey ZC crew,

    The link to the post above does pretty much cover describe how to add custom search terms. Here is another explanation that may be helpful to some and probably redundant to most

    I only had to edit one file: includes/modules/pages/advanced_search_result/header_php.php - this file generates a table of "search results."

    Some other posts mention editing the includes/index_filters/default_filter.php. I am not sure what this file does at the moment and the search modification seemed to work without so I'm not going to worry about it.


    When editing the header_php.php file, I echoed the search SQL query before it was executed. Here is the query when I searched for "123" (without quotes):
    Code:
    SELECT DISTINCT p.products_image, p.products_quantity , m.manufacturers_id,
    p.products_id, pd.products_name, p.products_price, p.products_tax_class_id,
    p.products_price_sorter, p.products_qty_box_status, p.master_categories_id
    FROM (products p LEFT JOIN manufacturers m USING(manufacturers_id),
    products_description pd, categories c, products_to_categories p2c )
    LEFT JOIN meta_tags_products_description mtpd ON
    mtpd.products_id= p2c.products_id AND mtpd.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 
    ((pd.products_name LIKE '%test%' OR p.products_model LIKE '%test%' OR
    m.manufacturers_name LIKE '%test%' OR (mtpd.metatags_keywords LIKE '%test%' AND
    mtpd.metatags_keywords !='') OR (mtpd.metatags_description LIKE '%test%' AND
    mtpd.metatags_description !='') OR pd.products_description LIKE '%test%') and
    (pd.products_name LIKE '%123%' OR p.products_model LIKE '%123%' OR
    m.manufacturers_name LIKE '%123%' OR (mtpd.metatags_keywords LIKE
    '%123%' AND mtpd.metatags_keywords !='') OR (mtpd.metatags_description LIKE
    '%123%' AND mtpd.metatags_description !='') OR pd.products_description LIKE '%123%') ))
    order by p.products_sort_order, pd.products_name
    If I were to summarize this query in human-speak, I'd say it: generates a table where each row contains all available text-descriptions of a product then filters the results by looking for "like (similar)" text, in this case "123."

    To incorporate custom attributes in the search, I just modified the query. Lets say, for example I have a table in by database called product_custom with the attributes (products_id, language_id, model_information). I would join this new table (I used the p2c (products_to_categories) table for the join values, i could have used another table but this one seemed convenient)
    Code:
     'LEFT JOIN product_custom pc on pc.products_id = p2c.products_id and pc.language_id = ' . $_SESSION['languages_id'] . '..'.
    select the attribute I want to search
    Code:
    select pc.model_information ...
    and compare the search term to the attribute, add
    Code:
    OR (pc.model_information  LIKE '%:keywords%')
    After re-reading the other post, I pretty much said the same thing but I hope this is helpful for some one

 

 

Similar Threads

  1. Show custom product fields in search results?
    By DigitalShadow in forum General Questions
    Replies: 2
    Last Post: 24 Jul 2011, 01:06 AM
  2. Add additional custom fields to Search Feature?
    By KismetDesign in forum Addon Sideboxes
    Replies: 0
    Last Post: 15 Jul 2009, 03:56 AM
  3. How do I change the look of the search bar?
    By monkeypeach in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 6 Oct 2008, 09:01 PM
  4. How can I change the look of the navigation side bar, to look like this
    By paha in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 12 Mar 2008, 04:45 AM
  5. Can I just use the product search feature? If so how?
    By pap74 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 27 Feb 2008, 05:17 AM

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