Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

manufacturer infobox list.. hashed together, but not quite there. help?


adibranch

Recommended Posts

Hi all, i'm replacing the dropdown manufacturer filter on product list pages with one which produces a list instead of the form drop down. I've nearly got it, but are not quite there with the sort option. The current filter produces a url such as "index.php?cPath=42_1449_45&sort=3a&filter_id=58" , but mine only returns "/index.php?cPath=42_1449_45?sort=&filter_id=58" , ie its missing the sort I.D . I'm not much a coder, more of a bodger, but have hashed together the following based on the original form filter...

<?php
if (PRODUCT_LIST_FILTER > 0) {
 if (isset($HTTP_GET_VARS['manufacturers_id'])) {
 $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.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";
 } else {
 $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";
 }
 $filterlist_query = tep_db_query($filterlist_sql);
 if (tep_db_num_rows($filterlist_query) > 1) {
 echo '<div>';
 while ($filterlist = tep_db_fetch_array($filterlist_query)) {
 $filterid = $filterlist['id'];
 $manuname = $filterlist['name'];
echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . substr(tep_get_path($category_id), 6)) . '?sort=' . $HTTP_GET_VARS['sort'] . '&filter_id=' . $filterid . '">' . $manuname . '</a><br>';
 }
 }
 echo '</div>';
}
?>

Link to comment
Share on other sites

if (isset($HTTP_GET_VARS['filter_id']) && !empty($HTTP_GET_VARS['filter_id'])) {
 // manufacturer list
 $manufacturers_list = '<ul>';
 while ($filterlist = tep_db_fetch_array($filterlist_query)) {
   $manufacturers_name = ((strlen($filterlist['name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($filterlist['name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $filterlist['name']);
           if (isset($HTTP_GET_VARS['filter_id']) && ($HTTP_GET_VARS['filter_id'] == $filterlist['id'])) $manufacturers_name = '<strong>' . $manufacturers_name .'</strong>';
   $manufacturers_list .= '<li><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('filter_id')) . 'filter_id=' . $filterlist['id']) . '">' . $manufacturers_name . '</a></li>';
 }

 $manufacturers_list .= '</ul>';
 echo $manufacturers_list;

 // in case re-use the SQL query
 mysql_data_seek($filterlist_query, 0);
}

Link to comment
Share on other sites

Thanks ! that works.. kinda.. (for reference, this is being put in an infobox). Yours only showed up the list when a manufacturer had already been selected. So, I couldnt use it as I couldn't suss how to fix it. Either way, I've now removed the sort part of the URL as the resulting page canonical doesn't include, it, and it obviously has to be the same. So, I now have the following.. could still be tidied though with the URL format? Mine is a bit of a bodge..

<?php
if (PRODUCT_LIST_FILTER > 0) {
 if (isset($HTTP_GET_VARS['manufacturers_id'])) {
 $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.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";
 } else {
 $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";
 }
 $filterlist_query = tep_db_query($filterlist_sql);
 if (tep_db_num_rows($filterlist_query) > 1) {
 echo '<ul>';
 while ($filterlist = tep_db_fetch_array($filterlist_query)) {
 $filterid = $filterlist['id'];
$manuname = $filterlist['name'];
echo '<li><a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . substr(tep_get_path($category_id), 6)) . '?filter_id=' . $filterid . '">' . $manuname . '</a></li>';
 }
 }
 echo '</ul>';
}
?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...