Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Category display limiting


Recommended Posts

Can someone help out? I have done a large site for a company with over 10,000 products. Automotive related. I have added a field to the products table for a vehicle manufacturer code similar to product manufacturer code and also added tables similar to the manufacturer tables. I have modified the site and created a sub site that shows only products with a certain vehicle code. But I cannot figure out how to limit the display of the categories if they do not have a product in it with that specific vehicle code. In other words, there are 800 categories, but if a customer wants a Nissan product, there may be only 10 categories that contain Nissan products. So we need to not show the other 790 categories.


Thanks for all input.


By the way, osCommerce is great! Thanks to the developers!

Link to comment
Share on other sites

I've looked at that to a certain degree and it may work, except I have a couple of questions.


1. Where is the 'filter_id' specified in the program. I found it in index.php (default.php) but can't tell where it gets it's designation, unless it is from the input from the manufacturers drop down.


2. Can it be made sticky?


On the other approach, I have everything working except the categories menu and categories page. I think I have the format figured out in regards to what needs to be done, I just don't know how to write the code.


Here is the basic overview of what I am guessing is correct:


There is a field in the products table I added called vehicle_manu.


I have also added a table called vehicle, which is just a copy of manufacturers.


I have edited the files on the sub-site to only access the products designated with a certain code, in this case vehicle_manu = 14, and this is functional at this time.


What I don't know is this:


I need the code to perform the query as well as generate the output for categories of basically this:


table categories where categories_id that has products_to_categories with products_offroad that have the assigned value of vehicle_manu = 14.


I also am not sure if this code would just go into general.php as a function or if it needs to go into categories.php or if would need to be inserted into all files affected (index.php, product_info.php, etc.....)


Seems like it could just go into general as a function.?.


Thanks for the quick response, by the way, you guy's are great.

Link to comment
Share on other sites

1. This is the dropdown form code from index.php (similar code in includes/boxes/manufacturers.php):

      if (tep_db_num_rows($filterlist_query) > 1) {
       echo '            <td align="center" class="main">' . tep_draw_form('filter', FILENAME_DEFAULT, 'get') . TEXT_SHOW . ' ';
       if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
         $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
       } else {
         echo tep_draw_hidden_field('cPath', $cPath);
         $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
       echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
       while ($filterlist = tep_db_fetch_array($filterlist_query)) {
         $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
       echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
       echo '</form></td>' . "\n";

2. Sticky? I'm not sure what you mean. If you want it to persist from page to page, you could add code to tep_href_link to carry it if present (like session ID) or store it in the session. You could also modify the relevant calls to include it if present. tep_get_all_get_params is made to carry all parameters (except those listed to be excluded), if that helps you.



        $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.vehicle_manu = '" . (int)$HTTP_GET_VARS['vehicle_manu'] . "' order by cd.categories_name";

Assumes that you are carrying the vehicle_manu value by which you would like to restrict in the URL as vehicle_manu=14 (or whatever id number). I would add this to index.php. I don't think that it matters on other pages. index.php is the page that navigates categories.




Link to comment
Share on other sites

Matt, thanks for the quick response again!


By sticky, yes, I do mean from page to page. If I can do that, your solution is probably the best, because then I don't have to worry about separate sub sites.


I'll play around with the info from the last post in a minute.


As far as the other approach, I was able to come up with the sql query I was looking for. It works in MySQL, now, how to incorporate it into osCommerce?


Select categories.categories_id, products_to_categories.products_offroad


categories, products_to_categories, products








Thanks again.

Link to comment
Share on other sites



I looked at the manufacture filter and am not sure to make that apply to my situation.


I also tried working in the direction with the query I posted in my last post, but discovered I was going about things backwards. The system already displays results, so I need to filter out the results.


I found a thread that had some code regarding hiding empty categories but the link to the thread say's article doesn't exist.


If you or anyone out there is interested, I am ready to talk compensation (money). Actually, have been all along.


Thanks for the input.

Link to comment
Share on other sites

  • 5 months later...


This topic is now archived and is closed to further replies.

  • Create New...