Site maintenance: Sun 15 Nov, from 12:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / All Other Contributions/Addons / Product Finder: multiple category drop-downs

Product Finder: multiple category drop-downs

Started by torvista on 5 Aug 2010, 7:08 PM · Views: 48,999

Results 1 to 20 of 225
5 Aug 2010, 7:08 PM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Product Finder: multiple category drop-downs

This mod provides three drop-down select boxes which are used to select products from subcat01 - subcat02 - subcat03 such as Make-Model-Year.

The second and third drop-down are populated dynamically (using jquery) as a result of the choice made in the previous box.

As supplied in this package, the drop drown is integrated into the header.

Why use this mod?

To replace a long static list in a sidebox.This mod was written for my site by a commercial developer as no equivalent was available as a community contribution.

This version 0.9 is offered to help those who wish to implement something similar. Since it is working for me I have not had to bugfix it and so I have no idea how it works and so cannot offer any support other than moral.

It is offered to the community "as is" in the hope that others pick it up and iron-out any non-Zen-standard-practices that may lurk within.

As it is, it works when dropped into a classic-copy vanilla 139e site.

Download at: http://www.zen-cart.com/downloads.php?do=file&id=1141

regards
Steve

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

24 Aug 2010, 6:31 PM
#2
sonik_fury avatar

sonik_fury

New Zenner

Join Date:
Aug 2010
Posts:
28
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

AWESOME!!:clap:

25 Aug 2010, 8:51 PM
#3
melirlbr avatar

melirlbr

New Zenner

Join Date:
Dec 2009
Posts:
25
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

This add-on looks great, but is it possible to have this in a sidebox?

27 Aug 2010, 6:27 PM
#4
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

from another thread (http://www.zen-cart.com/forum/showthread.php?t=160761&page=2%29:

I'm having issues getting it to work in the way I need and I think it is because I'm looking for it to utilize the current category location instead of defining the category #, but it's a step in the right direction.

Just to confirm in your setup, do you have Make options setup as you top level categories, Models setup as subcategories of Make, and Year setup as a subcategory of Models? Is there a chance you can post a link the the site it is used on?

My Top-level categories are:
1 - Manufacturers
2 - Products
3 - Your Bike

All products are defined (master cats) in Manufacturers as per the manufacturers product families and then linked to the Products and Your Bike categories.

Your Bike subcats are Bike Manufacturers (Aprilia, Benelli etc) then in each one specific models (RSV Mille, Pegaso etc..) then in each model a subcat for a specific year or range of years.

So to answer the question, the makes are the second level category.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

30 Aug 2010, 7:33 AM
#5
byoriginaldesign avatar

byoriginaldesign

New Zenner

Join Date:
Apr 2009
Posts:
84
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

torvista, thanks again for a great contribution. melirlbr, this can be added to just about anyplace you want, just add the modified line in the tpl_header.php, between <!--BOF Product Finder--> and <!--EOF Product Finder--> to the relevant php file you want it added to, then adjust the CSS file to your needs.

I'm having issues with this add on personally though, and I've yet to figure out the cause. I'm adding the code to tpl_index_categories, as I prefer it be on the category page above the category description. Because the first pulldown is a second level category I wanted it to use $parent_id = $current_category_id instead of defining the category ID.

In any case, I've tried it in both the header and in the category page, both with and without defining the category ID, have my categories and test product added, yet the 2nd pulldown will not pull data.

I've verified all files are uploaded, but I am stumped. With regards to the readme, there is a reference to a problem and a fix with the .htaccess file, do you know how the add-on interacts when this issue happens? I'm using multi-site module so that may have something to do with it, though the page I'm testing on is the primary domain with all redirected to www.

Page testing, https://www.printdealz.com
Test product under postcards, cardstock, 14pt

Brian - Connecticut, US --- Using Zen 1.3.9g - Modified Classic Template
Currently developing: http://www.printdealz.com
Other Zen Pages: http://www.wholesale4realtors.com 1.3.8a

30 Aug 2010, 4:21 PM
#6
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

torvista, thanks again for a great contribution.
well its not so great if it doesn't work!!

Have you tried it on a fresh 139 test site?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

31 Aug 2010, 5:25 AM
#7
byoriginaldesign avatar

byoriginaldesign

New Zenner

Join Date:
Apr 2009
Posts:
84
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

It is throwing a script error from the jscript, so that is most likely the issue, and yes it does work fine with a fresh install. I have a developer starting working on my needs on Thursday, so in a few weeks I should have an addition to this contribution.

The developer is adding a few tweaks, such as the 2nd pulldown will become visible following the 1st pulldown choice, 3rd after 2nd is chosen, and so on... the pulldowns will not be set to 3 levels and will stop if no further sub-categories exist, and the page itself will display the new sub-category's description without a page reload so you can add details about the next step of options, and hopefully at the last step it will also wrap the product list and product detail page dynamically as well. :yes:

Brian - Connecticut, US --- Using Zen 1.3.9g - Modified Classic Template
Currently developing: http://www.printdealz.com
Other Zen Pages: http://www.wholesale4realtors.com 1.3.8a

31 Aug 2010, 11:45 AM
#8
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

Version 0.9 in the downloads section requires a minor correction in the jscript_model_year.js file to display the breadcrumb elements correctly on the results page.

find around line 13

var cPath1=$("#select_model").val();
var cPath2=$("#cPath").val();

change to

var cPath1=$("#cPath").val();
var cPath2=$("#select_model").val();

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

4 Sep 2010, 5:27 AM
#9
jerr avatar

jerr

New Zenner

Join Date:
Sep 2010
Location:
California
Posts:
22
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

Hello .... Newbie here

I have been developing a ecommerce site using Oscommerce but decided to try Zencart. So far it has been much easier to install and setup.

I do have a problem though and I have searched and looked but have not found my answer so I will post it here because it relates to the Product Search add on.

I have it installed but I have a question about the master category number that I need to change on line 56 of the product finder.php. Where do I find it. Is it the number that appears adjacent to the category folder after the category has been added.?

jerr

4 Sep 2010, 6:17 AM
#10
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

Is it the number that appears adjacent to the category folder after the category has been added.?

Yes, also known as the cPath - look a the the address of a product page and you see how it is built up from category paths and the product id, eg:
cPath=1_4_30&products_id=79
where 1 is the top category, 4 and 30 subcats and 79 the product number.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

4 Sep 2010, 1:54 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Product Finder: multiple category drop-downs

Another way to look at the master_categories_id is to think of your Categories as more than just navigation to Products ...

If a Product belongs to 1 Category ... then that Category will have a categories_id that will match the master_categories_id ...

If a Product belongs to 2 or more Categories ... then only 1 of the 2 Categories can "own" the Linked Product ... it is the Category that "owns" the Product that is the categories_id for the master_categories_id ...

The purpose of that is for when it is not known where to go in navigation or for pricing information, such as SaleMaker, etc.

When navigating through the Categories, the immediate Category is known, as torvista has indicated, by the $cPath ...

To further specify the immediate Category there is the $current_category_id ... which helps in directing Products to the right Category ...

However, sometimes, the Category ... $cPath or $current_category_id ... is not known such as on a search or random creation of Products for display ...

This is where the $master_categories_id comes in ...

If you do not use Linked Products, this is simple to fix, by going to the Tools ... Store Manager ... and using the:

Reset ALL Products Master Categories ID
to be used for Linked Products and Pricing: Reset

Which you then want to follow up with:

Update ALL Products Price Sorter
to be able to sort by displayed prices: Update

The Products Price Sorter is used to help with sorting by price without having to do all kinds of calculations in the Catalog, as this is kept current in the Admin, as Products are added/edited ...

If you have Linked Products, then the master_categories_id may not be set right by using the update in the Store Manager, as it is updating based on the first categories_id that is found in the products_to_categories table ... and that table is ordered by categories_id ...

So if a Linked Product is linked to categories_id 23 and then to categories_id 3 ... categories_id 3 would be picked for updating the master_categories_id ...

Now, if you can run the Update Master Categories ID and then go to Catalog ... Categories/Products ... you will see an C for Copy on the Products ... hit the Multiple Categories Link Manager ...

At the bottom of the screen, you will see a place to update all of the Products in a Category to use that categories_id as its master_categories_id ...

Reset ALL Products in the selected Category to use the selected Category as the new Master Categories ID ...
Example: Resetting Category 22 would set ALL Products in Category 22 to use Category 22 as the Master Category ID
Reset the Master Categories ID for All Products in Category:

You can always set the master_categories_id yourself when editing the Product ...

NOTE: the option for setting the master_categories_id is only available if the Product is in 2 or more Categories and then you can only choose from those Categories ...

NOTE: always backup your database before using these features ...

NOTE: it is better to have a wrong master_categories_id than no master_categories_id where the master_categories_id is set to 0 ... you can always clean these up ...

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!

4 Sep 2010, 11:04 PM
#12
jerr avatar

jerr

New Zenner

Join Date:
Sep 2010
Location:
California
Posts:
22
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

Thanks for the help torvista and ajeh. I thought I had the product finder set but find now that I do not.

My problem is it installed ok but nothing is appearing as shown in the readme file. In other words the product finder does not appear to be working. I have gone over the install and see no problems there.

I am using a site template, will that or can that cause a problem. I guess I am confused on the category and sub category setup. A block diagram would help me being a retired tech.

jerr

5 Sep 2010, 7:12 AM
#13
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

nothing is appearing as shown in the readme file
The images in the readme are from my site, yours wont look like that.

If you have three drop downs in which 2 and 3 auto-update and you can search the categories and it produces a results page it is working.

"If at first you don't succeed - use the classic template"

or better still, make a copy of it for occasions like this where you don't know if the problem is the mod or your template.
Use the classic copy as a testbed.

If it does not work, the install is not correct. Check the reported files sizes of uploaded files.

You have not actually said what the problem is.
Link to your site?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

5 Sep 2010, 7:19 AM
#14
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

Another way to look at the master_categories_id is to...:shocking:
Thanks for that answer Ajeh, it looks like it should be in a wiki not buried here.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

5 Sep 2010, 4:24 PM
#15
jerr avatar

jerr

New Zenner

Join Date:
Sep 2010
Location:
California
Posts:
22
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

torvista:

You have not actually said what the problem is.
Link to your site?

Thanks Torvista. I do not have the site posted publicly yet, I am using my PC as a server until I have it developed.

I will try the classic and see if it works there for me. If not then I will go over the install again.

Basically my problem is how to input data, "category1, category2, category3" or "category, sub-category, sub-category- sub-category, product". I hope that makes sense.

jerr

5 Sep 2010, 10:12 PM
#16
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

It would be putting the cart before the horse to build your categories so this mod works with them.

All I can say is to repeat what I have stated earlier as to how my site is arranged and how this mod works with it.
If that does not square with your plan, then mod the mod (or get someone to do it).

My Top-level categories are:

1 - Manufacturers: all my products are defined here (master cats) and structured in subcategories reflecting the manufacturers product families and how my invoicing software is set up in the hope that one day they will be connected....
Note that this has nothing to do with the usual Zen Cart manufacturers information which is treated apart. I use a custom sidebox to display this category similarly to the standard Manufacturers sidebox but it works better (in my opinion).

2 - Products: the "traditional" idea of type-of-product categories. Everything here is linked from the Manufacturers section.
I use a custom sidebox which shows only the first level of description, subcategory navigation is done on the main page content.

3 - Your Bike
subcat1:eg. Aprilia
subcat2:eg. Pegaso
subcat3:eg. 2003-2005
Everything here linked from the Manufacturers section.

I use the Product Finder to give me drop down selects for subcat1, subcat2 and subcat3. So note that there are four category levels in use with the Product Finder.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

8 Sep 2010, 5:57 PM
#17
autolider avatar

autolider

New Zenner

Join Date:
Jul 2010
Posts:
5
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

Jerr:

Thanks Torvista. I do not have the site posted publicly yet, I am using my PC as a server until I have it developed.

I will try the classic and see if it works there for me. If not then I will go over the install again.

Basically my problem is how to input data, "category1, category2, category3" or "category, sub-category, sub-category- sub-category, product". I hope that makes sense.

jerr
Hi to all.
I have the same problem like JERR
-how to input data? : "category1, category2, category3" or "category, sub-category, sub-category- sub-category, product".
Is anybody here to explain how ?

8 Sep 2010, 8:33 PM
#18
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

This mod uses a category set-up like this

top-category -

sub-category level 1 -
subsub-category level 2 -
subsubsub-category level3 which contains the product

Each subcategory is a drop-down.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

12 Sep 2010, 8:16 AM
#19
sonik_fury avatar

sonik_fury

New Zenner

Join Date:
Aug 2010
Posts:
28
Plugin Contributions:
0

Re: Product Finder: multiple category drop-downs

!!! IMPORANT...you HAVE to have a product listed for the Main Cat or Subcats to pick up!!!

I thought it wasn't working either until I added a product to my site....it works great now.

Torvista, does yours show up the same in ALL browsers(chrome/FF/IE) my drop-down menus move around in different browsers.........any idea why???

12 Sep 2010, 8:44 AM
#20
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: Product Finder: multiple category drop-downs

!!! IMPORANT...you HAVE to have a product listed for the Main Cat or Subcats to pick up!!!
Can you explain that in a different way, I don't understand.
Do you mean the product has to be enabled or it has to exist in another category?

Browsers: The code formatting and accompanying css in the original version available for download is somewhat "inelegant".
I have since cleaned it up a bit which (illogically) fixed an issue with the main search at the end of the bar requiring a significant negative top margin in IE6 and IE7 to line it up correctly
I did not have any problems with other browsers though.
Your page width may cause overflow issues.

Updated code:

<!--BOF Product Finder-->
<div class="clearBoth"></div>
<div id="product_finder_wrapper">
  <div id="product_finder">
    <?php 
     echo "<form action=''>";            
?>
    <ul>
      <?php
   echo "<li>";
   $model1[]=array('id'=>'','text'=>TEXT_PLEASE_SELECT);
     if(isset($_REQUEST['cPath1'])){
     $value=$_REQUEST['cPath1'];
     }     
     echo '<span id="pf_title">'.strip_tags(TEXT_FIND_ALL_PRODUCTS).'</span>
     <span class="pf_selectbox_name">'.TEXT_MAKE . '</span>' . zen_draw_pull_down_menu('cPath1',array_merge($model1,zen_get_category_tree()),$value, 'id="cPath" class="searchSelectClass"'); 
     echo "</li>";
   
    echo "<li>";   
    echo "<noscript>";
    echo zen_my_image_submit(PF_NOSCRIPT_SUBMIT);
//echo zen_draw_input_field("submitButton","Go",'','submit');
         if($_REQUEST['cPath1']!=""){
               $value=$_REQUEST['cPath1'];
               $dropdownArray=zen_get_category_tree($value);
         }
echo "</noscript>";
echo "</li>";      

echo "<li>";
      $modulePath="".DIR_WS_CATALOG;
      echo zen_draw_hidden_field('basemodulepath',$modulePath,'id="basemodulepath" ');
     $model=array();
     $model[]=array('id'=>'',
                     'text'=>TEXT_PLEASE_SELECT
                     );
       if($_REQUEST['cPath1']!=""){
        $model=array_merge($model,$dropdownArray);
        }
    if(isset($_REQUEST['select_model'])){
    $value=$_REQUEST['select_model'];
    }
     echo '<span class="pf_selectbox_name">' . TEXT_MODEL .'</span>' 
     . zen_draw_pull_down_menu('select_model', $model, $value,  'id="select_model" class="searchSelectClass"'); 
echo "</li>";

echo "<li>";
echo "<noscript>";
if($_REQUEST['select_model']!=""){
               $value=$_REQUEST['select_model'];
               $dropdownArray=zen_get_category_tree($value); 
         }
echo zen_my_image_submit(PF_NOSCRIPT_SUBMIT);         
//echo zen_draw_input_field("submitButton","Go",'','submit');
echo "</noscript>";
echo "</li>";

echo "<li>";
     $year=array();
     $year[]=array('id'=>'',
                     'text'=>TEXT_PLEASE_SELECT
                     );
      if($_REQUEST['select_model']!=""){
        $year=array_merge($year,$dropdownArray);
        }                                  
if(isset($_REQUEST['cPath'])){
          $value=$_REQUEST['cPath'];
}
if($_REQUEST['select_model']!=""){
     echo '<span class="pf_selectbox_name">' . TEXT_YEAR . '</span>' . 
     zen_draw_pull_down_menu('cPath',$year , $value,  'id="select_year" class="searchSelectClass"');
     }
else {
     echo '<span class="pf_selectbox_name">' . TEXT_YEAR .'</span>' .
     zen_draw_pull_down_menu('cPath22',$year , $value,  'id="select_year" class="searchSelectClass"');
}     
echo "</li>";

echo "<li>";
echo "<noscript>";
if($_REQUEST['cPath']!=""){
         $value=$_REQUEST['cPath'];
         }
echo zen_my_image_submit(PF_NOSCRIPT_SUBMIT);
echo "</noscript>";
echo "</li>";
?>
</ul>
    </form>
    <div id="navMainSearch">
      <?php require(DIR_WS_MODULES . 'sideboxes/search_header.php'); ?>
    </div>
    <!--close navMainSearch div--> 
  </div>
  <!--close product_finder div--> 
</div>
<!--close product_finder_wrapper div-->
<div class="clearBoth"></div>
<!--EOF Product Finder-->

Updated style_product_finder.css
Note this is MY unadulterated css with white text, I include it so you can edit the correct selectors.

@charset "utf-8";
/* CSS Document /
/styles for Product Finder mod/
#product_finder_wrapper {
background-image:url(../images/background_bg.gif);
background-repeat:repeat;
margin:0 auto;
width:960px;
padding:10px 0 0 0;
border-top-width: 1px;
border-top-style: solid;
border-top-color: white;
}
#product_finder {
background-image: url(../images/search_bar.png);
background-repeat:no-repeat;
height:41px;
width:100%;
padding:8px 0 0 0;/otherwise text is top-aligned/
font-weight:bold;
color:#FFFFFF;
}
#product_finder ul {
}
#product_finder ul li {
list-style:none;
float:left;
margin-right:10px;/space between the drop-down items/
}
#pf_title {/
"Show Products for..."*/
font-weight:bold;
font-family:arial;
font-size:14px;
color:#FFFFFF;
margin-right:5px;
}
.pf_selectbox_name {/text in front of drop-down select box/
font-weight:bold;
font-family:arial;
font-size:13px;
color:#FFFFFF;
margin-right:2px;/space beween the drop-down name and the drop-down box/
}
#navMainSearch {
float: right;
}

regards
Steve

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...