Forums / Setting Up Categories, Products, Attributes / Search Category - Is this possible?

Search Category - Is this possible?

Locked

Views: 3,196

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
13 Apr 2008, 4:58 AM
#1
chrisroge avatar

chrisroge

New Zenner

Join Date:
Oct 2007
Posts:
15
Plugin Contributions:
0

Search Category - Is this possible?

Is it possible to create a 'search category'?

What I hope to do is create 1 category for each manufacturer, place all of that manufacturer's products in that 1 category. Then I would want to create many 'search categories' that would display the products that matched keywords or other criteria.

Lets say I have the following manufacturers and products:

manufacturer1 | product01 | 19.99 | product description keywords A
manufacturer1 | product02 | 24.99 | product description keywords B

manufacturer2 | product03 | 29.99 | product description keywords C
manufacturer2 | product04 | 14.99 | product description keywords A
manufacturer2 | product05 | 11.99 | product description keywords D

Example "Search Category 1" would show all products that have "keywords A"
Example "Search Category 2" would show all products priced $20 - $30

Of course thinking here if this is possible you could use whatever criteria you want, the above are just some simple examples to express this idea.

I love Zen Cart, but the way products are copied and linked from one category to another is a bit hard to follow, so really I want to do this to 1) save the trouble of copying/linking products between categories and 2) have a really clean and simple "real" category structure in my store admin.

I hope someone else is thinking about this too, maybe we can work together to make it work, I have some understanding of the Zen DB structure and some PHP knowledge...

Thanks,
Chris

13 Apr 2008, 5:05 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Search Category - Is this possible?

It will search the description and other fields....have a look at the advance search function if you have the search sidebox enabled

Zen-Venom Get Bitten

13 Apr 2008, 12:43 PM
#3
chrisroge avatar

chrisroge

New Zenner

Join Date:
Oct 2007
Posts:
15
Plugin Contributions:
0

Re: Search Category - Is this possible?

Right. Appreciate that. However what I am hoping to do is create a category that does not contain products, but instead contains a search for products. Hope this makes sense. I had this feature using another shopping cart SW and hope to also have it with Zen.

So you would have a product category that would sit in with all the actual categories (seamless to the site visitor) that has a category image etc but just returns search results.

Something like this:

Category1 | Contains actual product IDs from the DB
Category2 | Contains actual product IDs from the DB
Category3 | Contains no products, instead returns results of products < $100
Category4 | Contains no products, instead returns results of products with keyword A

So again to the visitor this would just be a listing of categories, but to the system Categories 3 and 4 are just search results.

13 Apr 2008, 4:08 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Search Category - Is this possible?

This, from your description, is not a default feature and would require custom coding

Zen-Venom Get Bitten

13 Apr 2008, 4:36 PM
#5
chrisroge avatar

chrisroge

New Zenner

Join Date:
Oct 2007
Posts:
15
Plugin Contributions:
0

Re: Search Category - Is this possible?

Thanks for confirming that. I am wondering if anyone has any thoughts of where to start to get the ball rolling on this idea?

My first thinking is look for the code that querries the database for products when someone clicks on a category we would instead read a new table that would have:

categories_id = 1 | search parameter1
categories_id = 1 | search parameter2
(etc)

Then the code would return the search results instead of the usual products associated with a category.

So basic logic would be:

  1. visitor clicks on categories_id '1'
  2. if categories_id '1' exists in the new table 'categories_search' then proceed to step 3... if not skip to step 4
  3. run a query based on all search parameters listed for categories_id '1' in 'categories_search' table and return those results to the visitor
  4. return usual category results from DB. (if step 3 were run it would not hurt to continue on to step 4 anyway to return any products implicitly listed in categories_id '1'?)

Anyway hope someone can help here. I dont yet have the expertise to make this all happen in zen cart...

13 Apr 2008, 6:37 PM
#6
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Search Category - Is this possible?

Why do you even have to think about something like that? Basically you just want a link that people can click on and will return a search.

You can just fake it, make it look like a category, and the link actually a search link.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

13 Apr 2008, 7:38 PM
#7
chrisroge avatar

chrisroge

New Zenner

Join Date:
Oct 2007
Posts:
15
Plugin Contributions:
0

Re: Search Category - Is this possible?

You make a good point. But I would want to take advantage of the other features that the actual Zen categories offer, like a category image and description editable in the admin.

Perhaps I could use EZ pages to make these 'search categories?' Just thinking out loud as I have not yet played with EZ pages yet.

Thanks for the suggestion! (Would still be nice to code actual search categories though!)

Chris

13 Apr 2008, 7:46 PM
#8
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Search Category - Is this possible?

perform a search and then view the source for the code

Zen-Venom Get Bitten

23 Apr 2008, 6:29 PM
#9
chrisroge avatar

chrisroge

New Zenner

Join Date:
Oct 2007
Posts:
15
Plugin Contributions:
0

Re: Search Category - Is this possible?

So I took your advice and did a search and viewed the code. I think I have a solution that will work for me, but is far from "contribution' material yet...

Note: I am running Zen 1.3.7 so that is the platform these changes were made with.

What this does: When you click on a category this checks if the category description exists and also checks how many products are in the category. If there are 0 products and there is a category description the script assumes you want to do a advanced search using the text you place in the category description field. If there are more than 0 products in the category the normal product results are returned.

So for example: say you want to create a 'search category' for the term "ducks". You would first do a advanced search from your store catalog for the search term "ducks". To make the search even better you could do a search for perhaps "ducks or duckies" (leave our the quotes when doing your search). The results are of course any products from your catalog that contain the words "ducks" or "duckies". So now you copy from the URL starting with "advanced_search_result" and everything after that to the clipboard:

http://www.YOUR_STORE/index.php?main_page=advanced_search_result&keyword=ducks+or+duckies&search_in_description=1&categories_id=&inc_subcat=1&manufacturers_id=&pfrom=&pto=&dfrom=&dto=&x=0&y=0

Now to complete this example you would create a new category, perhaps named "Ducks and Duckies" (the name does not matter) and you would paste the contents of the clipboard to the categories description field. Save the category. Now when you click on the category "Ducks and Duckies" from your storefront you are really seeing a search query for the terms you created from your advanced search result.

You can do the same for any search criteria, for instance if you wanted to show all products between $1 and $50 you could do that too.

Something to note is of course it would be better to create a new category field - something like "search terms"... or maybe even a few more category fields like "price from" and "price to" to avoid having to hijack the categories description field for this. Maybe someone can do that or if I find the time I could take a crack?

So here are the changes you will need to make to make this work for you: (no files are edited unless you already have a copy of tpl_index_product_list.php or advanced_search_result.css in your custom_template folders. Also no edits to the DB (yet!)

To add "search categories" functionality to your Zen Cart:

Step 1: Edit /includes/templates/your_template/templates/tpl_index_product_list.php (if this file does not exist copy it from /includes/templates/template_default/templates to /includes/templates/your template/tpl_index_product_list.php)

Find the following code:

<?php
// categories_description
    if ($current_categories_description != '') {
?>
<div id="indexProductListCatDescription" class="content"><?php echo $current_categories_description;  ?></div>
<?php } // categories_description ?>

Replace it with:

<!-- CGR - Begin Categories Search Function   -->
<?php include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING)); ?>
<?php
// categories_description
    if ($current_categories_description != '') {
// CGR - This next line will tell us if there are any products in the category, if there are none then don't show the description    
    if ($listing_split->number_of_rows > 0) {
?>
<div id="indexProductListCatDescription" class="content"><?php echo $current_categories_description;  ?>
</div>
<?php }} // categories_description ?>

<div id="categoriessearchresults">
<?php 
$categories_search_url = HTTP_SERVER . DIR_WS_CATALOG . 'index.php?main_page=' . $current_categories_description;
?>
<?php
// categories_description
    if ($current_categories_description != '') {
    if ($listing_split->number_of_rows == 0) {
?>
<?php include ($categories_search_url); ?>
<?php }} // categories_description ?>
</div>
<!-- CGR - END Catagories Search Function  -->

Step 2: Create /includes/templates/your_template/css/advanced_search_result.css

Step 3: Copy the following CSS to your newly created CSS file:

#categoriessearchresults #headerWrapper, #categoriessearchresults #navColumnOne, #categoriessearchresults #navColumnTwo, #categoriessearchresults #navSuppWrapper, #categoriessearchresults #siteinfoLegal, #categoriessearchresults #navBreadCrumb	{
	display:none;
}

#categoriessearchresults .messageStackWarning, #categoriessearchresults .buttonRow	{
	display:none;
}

#categoriessearchresults .centerColumn	{
	width: 90%; color: purple;
}

Note: I made the color of the search results text purple so you can see the difference between a normal categories products result and a categories search result.

5 Dec 2008, 5:40 AM
#10
dmfelder avatar

dmfelder

Zen Follower

Join Date:
Nov 2006
Posts:
102
Plugin Contributions:
0

Re: Search Category - Is this possible?

Hello there. I know this is an old link, but it's about all I can find regarding a search for categories.

I am trying to modify my search function so that it ONLY looks at CATEGORY names, keywords, and descriptions rather than any product information. In other words, I only want categories to show up in my search results...NO PRODUCTS.

In your last post, you describe a mod called "search categories," but when I read everything else, does this routine really do what I'm looking for? It seems like you've just kind of faked a search for categories...but I don't clearly understand what your describing. Hence, this comment.

I imagine what I am looking to do is as simple as pointing the query to another table. I can do that with my eyes closed in VB, but my skills in PHP are limited.

Any advice you could throw my way would be greatly appreciated.

DMFelder | Visit GreatApparelForYou.com for Chicago Direct to Garment printing and Chicago Screen Printing and for Funny Tees and shirts go to gafy.com. We also have Eco-Friendly Printing services.

9 Mar 2009, 1:39 AM
#11
izilla_pod avatar

izilla_pod

New Zenner

Join Date:
Sep 2006
Posts:
26
Plugin Contributions:
0

Re: Search Category - Is this possible?

Chrisroge, I am trying to implement the "search categories" you described above. I followed your instructions; however, I can not get the searched products to display. I think there is an issue with the way you simply used a php include of the full URL of the search page, as seen here:

<?php include ($categories_search_url); ?>
``` Can you verify that this worked or does anyone else have any suggestions?