Zen Cart Logo
Forums / Addon Sideboxes / product filter module addon

product filter module addon

Views: 81,446

Results 81 to 100 of 169
1 Feb 2010, 12:30 AM
#81
cubitfx avatar

cubitfx

New Zenner

Join Date:
Jul 2007
Posts:
7
Plugin Contributions:
0

product filter module addon

For those of you that consistently get no search results, I have found the solution.

In includes\modules\pages\product_filter_result\header_php.php

After (line 44):

  if (isset($_GET['available'])) {
    $available = $_GET['available'];
  }

I added:

  else {
	$available = '0';
  }

Basically, the search doesn't default to searching for available items if you have this search parameter disabled in the config. Please post back if this worked for you so others know the results.

4 Feb 2010, 6:37 PM
#82
frumfell avatar

frumfell

New Zenner

Join Date:
Jul 2009
Posts:
7
Plugin Contributions:
0

Re: product filter module addon

hi, if someone has the same problem as me or flower, that is broken order in which attributes are displayed in filter box, i have found one solution, probably it is not the best way, but it works.

  1. add as many attributes values as you need, just instead of attributes values names put letters a,b,c,d,e,f ... and so on.
  2. go to shop site and note down in which order they are dispayed for example c,b,f,a,e,d
  3. go to database, see table "product_option_values"
  4. edit rows to change numbers in to attributes values names, swaping letters dispaled as the first with name you want to have displayed as the first.
    for example swap letter "c" to "size1", then "b" to size2", "f" to "size3", "a" to "size4" and so on.
    hopefully someone will find better solution for this problem, but any way it can be helpful for someone
5 Feb 2010, 12:55 AM
#83
cjsmiff avatar

cjsmiff

Zen Follower

Join Date:
Jul 2006
Location:
UK
Posts:
170
Plugin Contributions:
0

Re: product filter module addon

Am I able to put this module in the Search Header (replace the standard search header)?

Any ideas which code I'd need to edit please?

Cheers
Claire

9 Feb 2010, 8:40 PM
#84
webbies avatar

webbies

New Zenner

Join Date:
Feb 2010
Posts:
15
Plugin Contributions:
0

Re: product filter module addon

Hi Zenners,

The filter doesn't contain manufacturers so I put some code in the template:

	/*end  sort drop down *************************************************/
	if(SHOW_MANUFACTURER){
		$content .= zen_draw_pull_down_menu('manufacturers_id', zen_get_manufacturers(array(array('id' => '', 'text' => PRODUCT_FILTER_TEXT_ALL_MANUFACTURERS)), '0' ,'', '1'), (isset($_GET['manufacturers_id']) ? $_GET['manufacturers_id'] : ''), '') . zen_hide_session_id();
	}	
	
	$content .= '<br /><input type="submit" value="' . PRODUCT_FILTER_BUTTON_NAME . '" style="width: 65px" />';
	$content .= "</form>";
	$content .= '</div>';
	
	?>

At the front the manufacturers are there now:clap:
but when I choose one and click on Send the filter doesn't do a thing (the other filters do work (prices etc).:no:

What do I miss here?

Anybody?

Lieke

16 Feb 2010, 5:34 AM
#85
spazem avatar

spazem

New Zenner

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

Re: product filter module addon

My filter by price range is working after these few changes. My problem is that my side boxes are smaller then the catorgery text so the drop down box when its activated extends wider then the sidebox and looks awful.

Anyone know how to chnage the font size on the drop down or even better...

make it only filter results based on what catorgry you have selected and are currently in. this takes the need for it.

any help would be appriciated.

20 Feb 2010, 1:46 PM
#86
karimm avatar

karimm

New Zenner

Join Date:
Nov 2008
Posts:
53
Plugin Contributions:
0

Re: product filter module addon

Hello,

I have a strange problem, when i use the filter and switch to different options fast, no results is displayed and it seams the site is loading but nothing happends and i can't browse the website.

When i take a look at the taskmanager (windows), the mysql-nt.exe process uses about 75% of the cpu.

Could this be a server / database issue ?

Any suggestion will be more then welkome, i would really like to use this module.

Thanks,

10 Mar 2010, 1:35 AM
#87
cjsmiff avatar

cjsmiff

Zen Follower

Join Date:
Jul 2006
Location:
UK
Posts:
170
Plugin Contributions:
0

Re: product filter module addon

kburner:

I have been trying to get this mod working. Went through this forum and still will not work.

Error looks like this:
1104 The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
in:
[select count(distinct p.products_id) as total FROM products p, products_description pd, products_to_categories p2c, products_attributes pa, products_options po , products_options_values pov WHERE (p.products_status = 1 AND p.products_quantity > 0 AND p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_id = p2c.products_id) ]

Any suggestions?:frusty:
Thanks, Kim

Did you find a solution please Kim? I'm having the same problem.

Cheers
Claire :dontgetit

10 Mar 2010, 2:00 AM
#88
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: product filter module addon

cjsmiff:

Did you find a solution please Kim? I'm having the same problem.

Cheers
Claire :dontgetit

No. I am sorry to say --- I was never able to get this module working.

22 Mar 2010, 7:09 PM
#89
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: product filter module addon

Hi all!
I have the same problem as a few others....my filter result just brings back a page with the following error:

1104 The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
in:
[select count(distinct p.products_id) as total FROM zen_products p, zen_products_description pd, zen_products_to_categories p2c, zen_products_attributes pa, zen_products_options po , zen_products_options_values pov WHERE (p.products_status = 1 AND p.products_quantity > 0 AND p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_id = p2c.products_id) ]

I have the single listing template installed so maybe that's messing with this mod somehow?

Can somebody point me in the right direction on how to fic this?

Thank you!

22 Mar 2010, 7:28 PM
#90
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: product filter module addon

ok, I got past that error :clap:

In includes/templates/template_default/templates/tpl_product_filter_result_default.php

If you add the following line

$db->Execute("set sql_big_selects=1");

after this line

require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING_ALPHA_SORTER));

It works.
I'm not sure if this is masking an underlying problem though!

The filter now returns products but not what I've asked for!
It just returns anything that is in stock :(

24 Mar 2010, 4:37 PM
#91
pink avatar

pink

New Zenner

Join Date:
May 2009
Posts:
64
Plugin Contributions:
0

Re: product filter module addon

SCkatlyns:

I have tried and tried to get this mod to work. I get it installed and it shows up on the sidebox. The problem is that no matter what filter I choose, I do not get any products at all.

Can someone help?

Thanks,
Kat

The search-sql just lists products, if they are on stock. (see in sql: AND p.products_quantity > 0)

As I do not use zen-cart to control my stock, I didn't refer on this - but for this mod to work, one has to. Or one has to change the sql and get rid of "AND p.products_quantity > 0".

25 Apr 2010, 10:11 PM
#92
adamlonsdale avatar

adamlonsdale

New Zenner

Join Date:
Apr 2010
Posts:
22
Plugin Contributions:
0

Re: product filter module addon

Hey,

Having a couple of issues with this module. I've managed to fix the attribute and price filter. And that all works (Sort of).

I currently have two of everything. I.e two colour boxes and two size boxes. The module only works if you select the attribute twice. But in the attributes boxes I also have two of everything. So it looks like:

Size
32C
32C
34C
34C
36C
36C
38C
38C
28D
28D

etc.

How do I

a) Make there one of eac attribute filter
b) Make one of each option value
Regards,

Adam.

25 Jul 2010, 6:29 PM
#93
pink avatar

pink

New Zenner

Join Date:
May 2009
Posts:
64
Plugin Contributions:
0

Re: product filter module addon

Lavanya:

ok, as nobody answered i had to find out myself with the help of firebug and the delopers tool kit (indeed very helpfull both of them :smile:)
For any other zencart beginner like me who wants to know:
change in includes/templates/your template/templates/tpl_product_filter_result_default.php the line <h1 id="advSearchResultsDefaultHeading"><?php echo HEADING_TITLE; ?></h1> to

<h1 id="advSearchResultsDefaultHeading"><?php echo PRODUCT_FILTER_HEADING_TITLE; ?></h1> and then in product_filter_define.php the line define('HEADING_TITLE','Product Filter Results'); to define('PRODUCT_FILTER_HEADING_TITLE','Product Filter Results'); Like this the headers of my define pages don't get effected anymore by the product filter heading.

:clap: Thank you.

26 Jul 2010, 5:53 PM
#94
atmpartmart avatar

atmpartmart

New Zenner

Join Date:
May 2009
Posts:
14
Plugin Contributions:
0

Re: product filter module addon

atmpartmart:

Can anybody help me out with the error quoted below?

Thanks in advance. I'd love to get this installed as we have added so many products lately and it's getting harder for customers to find the specific product they are looking for.

Figured I'd try one more time to get some help on this. Can anybody help with the error I'm getting? Thank you


1054 Unknown column 'p.master_categories_id' in 'on clause'
in:
[select count(distinct p.products_id) as total FROM zen_products p, zen_products_description pd, zen_products_to_categories p2c, zen_products_attributes pa, zen_products_options po , zen_products_options_values pov LEFT JOIN zen_hide_categories h ON (p.master_categories_id = h.categories_id) WHERE (h.visibility_status < 2 OR h.visibility_status IS NULL) AND (p.products_status = 1 AND p.products_quantity > 0 AND p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_id = p2c.products_id) ]


4 Aug 2010, 4:35 PM
#95
jabbawest avatar

jabbawest

Zen Follower

Join Date:
Oct 2009
Location:
Texas
Posts:
197
Plugin Contributions:
0

Re: product filter module addon

I have read this thread over and over again, yet I still have not found a fix for the sort by price returning no results issue.
Everything else is working fine.

The prices of my products are determined by their attributes, which may be part of the problem.

Here's my header_php.php file after applying most of the suggested tweaks. The results of which can bee seen here
http://sterlingleafjewelry.com/index.php

<?php
/**
* header_php.php
*
*Zen Cart product filter module
  *Johnny Ye, Oct 2007
* update by Jan Cabicar, Apr 2009
  
  */
  


require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$error = false;
$missing_one_input = false;


if (isset($_GET['categories_id'])  && !is_numeric($_GET['categories_id'])){
  $error = true;
  $messageStack->add_session('filter', ERROR_AT_LEAST_ONE_INPUT);
} else {
	$categories_id ='';
}

$available = 'yes';

$option_ids = array();
$option_values = array();
foreach($_GET as $key => $value){
    if(substr_count($key,'options')>0)
	{
		$option_ids[sizeof($option_ids)] = str_replace('options_','',$key);
		$option_values[sizeof($option_values)] = $value;
	}
}
  
  
  if (isset($_GET['categories_id'])) {
    $categories_id = $_GET['categories_id'];
  }
  if (isset($_GET['price_range'])) {
    $price_range = $_GET['price_range'];
  }
  if (isset($_GET['available'])) {
    $available = $_GET['available'];		
	}
  if (isset($_GET['sort'])) {
    $sort = $_GET['sort'];
  }
  
  $price_check_error = false;
  if (zen_not_null($pfrom)) {
    if (!settype($pfrom, 'float')) {
      $error = true;
      $price_check_error = true;

      $messageStack->add_session('filter', ERROR_PRICE_FROM_MUST_BE_NUM);
    }
  }

  
$define_list = array('PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                     'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                     'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                     'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                     'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                     'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE);

asort($define_list);

$column_list = array();
reset($define_list);
while (list($column, $value) = each($define_list)) {
  if ($value) $column_list[] = $column;
}

$select_column_list = '';

for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  if (($column_list[$col] == 'PRODUCT_LIST_NAME') || ($column_list[$col] == 'PRODUCT_LIST_PRICE')) {
    continue;
  }

  if (zen_not_null($select_column_list)) {
    $select_column_list .= ', ';
  }

  switch ($column_list[$col]) {
    case 'PRODUCT_LIST_MODEL':
    $select_column_list .= 'p.products_model';
    break;
    case 'PRODUCT_LIST_MANUFACTURER':
    $select_column_list .= 'm.manufacturers_name';
    break;
    case 'PRODUCT_LIST_QUANTITY':
    $select_column_list .= 'p.products_quantity';
    break;
    case 'PRODUCT_LIST_IMAGE':
    $select_column_list .= 'p.products_image';
    break;
    case 'PRODUCT_LIST_WEIGHT':
    $select_column_list .= 'p.products_weight';
    break;
  }
}

// always add quantity regardless of whether or not it is in the listing for add to cart buttons
if (PRODUCT_LIST_QUANTITY < 1) {
  if (empty($select_column_list)) {
    $select_column_list .= ' p.products_quantity ';
  } else  {
    $select_column_list .= ', p.products_quantity ';
  }
}

if (zen_not_null($select_column_list)) {
  $select_column_list .= ', ';
}

// Notifier Point


$select_str = "SELECT DISTINCT " . $select_column_list .
              " m.manufacturers_id, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_price_sorter, p.products_qty_box_status ";


$from_str = " FROM " . TABLE_PRODUCTS ." p, " . TABLE_PRODUCTS_DESCRIPTION . "  pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS . " po , " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov ";


$order_str='';

$listing_sql = $select_str . $from_str . $where_str . $order_str;
$listing_sql = "select DISTINCT ";
$listing_sql .= "p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, p.products_price_sorter, p.products_qty_box_status ";

 
$where_str = " WHERE (p.products_status = 1  ";


$enable_attribute_filter = true;
if(sizeof($option_ids)>0){
	for($i=0;$i<sizeof($option_ids);$i++){
		if(!(empty($option_values[$i])))
		{
			$where_str .= " AND ((pa.products_id In (SELECT pa.products_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa WHERE (";
			$where_str .= " pa.options_id = ".$option_ids[$i];
			$where_str .= " AND pa.options_values_id = ".$option_values[$i];
			$where_str .= " )))) ";
			$enable_attribute_filter = true;
		}
	}
}
		

if($enable_attribute_filter){
	$where_str .= " AND p.products_id = pa.products_id";
	
		
$enable_price_filter = true;
switch($price_range){
	case 0:
		$pfrom = MIN_PRICE;
		$pto = MAX_PRICE;
	break;
	case 1:
		$pfrom = PRANGE1_MIN;
		$pto = PRANGE1_MAX;
	break;
	case 2:
		$pfrom = PRANGE2_MIN;
		$pto = PRANGE2_MAX;
	break;
	case 3:
		$pfrom = PRANGE3_MIN;
		$pto = PRANGE3_MAX;
	break;
	case 4:
		$pfrom = PRANGE4_MIN;
		$pto = PRANGE4_MAX;
	break;
	case 5:
		$pfrom = PRANGE5_MIN;
		$pto = PRANGE5_MAX;
	break;
}
if(SHOW_SORT){
	switch($sort){
		case 0:
			$order_str = " order by p.products_date_added DESC, p.products_date_available DESC, products_price ASC ";
		break;
		case 1:
			$order_str = " order by p.products_date_added ASC, p.products_date_available ASC, products_price ASC ";
		break;
		case 2:
			$order_str = " order by p.products_price ASC, p.products_date_added DESC, p.products_date_available DESC ";
		break;
		case 3:
			$order_str = " order by products_price DESC, p.products_date_added DESC, p.products_date_available DESC  ";
		break;
		$order_str = " order by p.products_date_added DESC, p.products_date_available DESC, products_price ASC ";
	}
}


if($categories_id !=''){
	$where_str .=" AND p2c.categories_id = ".$categories_id;
}

if($enable_price_filter){
	$where_str .= " AND p.products_price >= ".$pfrom;
	$where_str .= " AND p.products_price <= ".$pto;
}


}
if($available=='yes'){
$where_str .= " AND p.products_quantity > 0 ";	
}

$where_str .=" AND p.products_id = pd.products_id";
$where_str .=" AND pd.language_id = ".$_SESSION['languages_id'];
$where_str .=" AND p.products_id = p2c.products_id)	";


$listing_sql .= $from_str;
$listing_sql .= $where_str;
$listing_sql .= $order_str;


//$breadcrumb->add('title');


// This should be last line of the script:
?>
6 Aug 2010, 8:27 PM
#96
jabbawest avatar

jabbawest

Zen Follower

Join Date:
Oct 2009
Location:
Texas
Posts:
197
Plugin Contributions:
0

Re: product filter module addon

Does anyone have this box working with products priced by attributes?
It seems to be missing some code in order to get those values. I've been looking for clues in the includes/functions_price.php but, I haven't had any luck.

8 Aug 2010, 1:31 AM
#97
amirgtr avatar

amirgtr

New Zenner

Join Date:
Mar 2009
Posts:
45
Plugin Contributions:
0

Re: product filter module addon

Louis:

Hi All, I installed this mod but found that regardless of the criteria selected no items were shown. I started debugging and modified the header_php.php file a bit.

The scenario is as follows.

  1. The file as contained in the downloads folder will only work IF YOU HAVE ATTRIBUTES loaded against your products. I do not make use of attributes but I did like the idea of having a Price and Category search on my site.
  2. In the downloaded version there was a reference to a ZS_table. I fixed this by changing it to the correct variable so you no longer have to change the table prefix, it will be done for you.

To install this "fix" just override the header_php.php file contained in the contribution with the following:

<?php /** * header_php.php * *Zen Cart product filter module *Johnny Ye, Oct 2007 * update by Jan Cabicar, Apr 2009 */ require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php')); $error = false; $missing_one_input = false; if (isset($_GET['categories_id']) && !is_numeric($_GET['categories_id'])){ $error = true; $messageStack->add_session('filter', ERROR_AT_LEAST_ONE_INPUT); } else { $categories_id =''; } $available = 'yes'; $option_ids = array(); $option_values = array(); foreach($_GET as $key => $value){ if(substr_count($key,'options')>0) { $option_ids[sizeof($option_ids)] = str_replace('options_','',$key); $option_values[sizeof($option_values)] = $value; } } if (isset($_GET['categories_id'])) { $categories_id = $_GET['categories_id']; } if (isset($_GET['price_range'])) { $price_range = $_GET['price_range']; } if (isset($_GET['available'])) { $available = $_GET['available']; } if (isset($_GET['sort'])) { $sort = $_GET['sort']; } $price_check_error = false; if (zen_not_null($pfrom)) { if (!settype($pfrom, 'float')) { $error = true; $price_check_error = true; $messageStack->add_session('filter', ERROR_PRICE_FROM_MUST_BE_NUM); } } $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE); asort($define_list); $column_list = array(); reset($define_list); while (list($column, $value) = each($define_list)) { if ($value) $column_list[] = $column; } $select_column_list = ''; for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { if (($column_list[$col] == 'PRODUCT_LIST_NAME') || ($column_list[$col] == 'PRODUCT_LIST_PRICE')) { continue; } if (zen_not_null($select_column_list)) { $select_column_list .= ', '; } switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model'; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name'; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity'; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image'; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight'; break; } } // always add quantity regardless of whether or not it is in the listing for add to cart buttons if (PRODUCT_LIST_QUANTITY < 1) { if (empty($select_column_list)) { $select_column_list .= ' p.products_quantity '; } else { $select_column_list .= ', p.products_quantity '; } } if (zen_not_null($select_column_list)) { $select_column_list .= ', '; } // Notifier Point $select_str = "SELECT DISTINCT " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_price_sorter, p.products_qty_box_status "; $from_str = " FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS_OPTIONS . " po , " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov "; $order_str=''; $listing_sql = $select_str . $from_str . $where_str . $order_str; $listing_sql = "select DISTINCT "; $listing_sql .= "p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, p.products_price_sorter, p.products_qty_box_status "; $where_str = " WHERE (p.products_status = 1 "; $enable_price_filter = true; switch($price_range){ case 0: $pfrom = MIN_PRICE; $pto = MAX_PRICE; break; case 1: $pfrom = PRANGE1_MIN; $pto = PRANGE1_MAX; break; case 2: $pfrom = PRANGE2_MIN; $pto = PRANGE2_MAX; break; case 3: $pfrom = PRANGE3_MIN; $pto = PRANGE3_MAX; break; case 4: $pfrom = PRANGE4_MIN; $pto = PRANGE4_MAX; break; case 5: $pfrom = PRANGE5_MIN; $pto = PRANGE5_MAX; break; } if(SHOW_SORT){ switch($sort){ case 0: $order_str = " order by p.products_date_added DESC, p.products_date_available DESC, products_price ASC "; break; case 1: $order_str = " order by p.products_date_added ASC, p.products_date_available ASC, products_price ASC "; break; case 2: $order_str = " order by p.products_price ASC, p.products_date_added DESC, p.products_date_available DESC "; break; case 3: $order_str = " order by products_price DESC, p.products_date_added DESC, p.products_date_available DESC "; break; $order_str = " order by p.products_date_added DESC, p.products_date_available DESC, products_price ASC "; } } if($categories_id !=''){ $where_str .=" AND p2c.categories_id = ".$categories_id; } if($enable_price_filter){ $where_str .= " AND p.products_price >= ".$pfrom; $where_str .= " AND p.products_price <= ".$pto; } if($available=='yes'){ $where_str .= " AND p.products_quantity > 0 "; } $where_str .=" AND p.products_id = pd.products_id"; $where_str .=" AND p.products_id = p2c.products_id) "; $listing_sql .= $from_str; $listing_sql .= $where_str; $listing_sql .= $order_str; $listing_sql //$breadcrumb->add('title'); // This should be last line of the script: ?>
> 
> Thank you to the original author for this great mod.

This did it for me. You're my hero! :bigups:
8 Aug 2010, 2:02 PM
#98
jabbawest avatar

jabbawest

Zen Follower

Join Date:
Oct 2009
Location:
Texas
Posts:
197
Plugin Contributions:
0

Re: product filter module addon

Ok, wild goose chase is over.

Turns out to be an issue with editing the prices ranges in:
product_filter_defines.php and I'm not sure what I'm doing wrong.
I changed the minimum value to $1000 to see if it would find anything, and it did.
I put it back to $50 and continued to edit the values to reflect my shop, but again, it won't return any results.
Here is an example of what I have so far. Where am I going wrong here?

<?php
/**
* product_filter_defines.php
*
*Zen Cart product filter module
  *Johnny Ye, Oct 2007
  */
define('PRODUCT_FILTER_TEXT_ALL_CATEGORIES','All Categories');
define('PRODUCT_FILTER_TEXT_ALL_PRICE','Price Range');
define('FILENAME_PRODUCT_FILTER_RESULT', 'product_filter_result');
define('BOX_HEADING_FILTER', 'Advanced Search');

define('PRODUCT_FILTER_HEADING_TITLE', 'Your Search Results');
define('PRODUCT_FILTER_BUTTON_NAME', 'Search');
  
define('MIN_PRICE','0');
define('MAX_PRICE','1000000');

define('PRANGE1_WORD','Below $50');
define('PRANGE1_MIN',MIN_PRICE);
define('PRANGE1_MAX',50.00);

define('PRANGE2_WORD','$100 -- $500');
define('PRANGE2_MIN',100.00);
define('PRANGE2_MAX',499.99);

define('PRANGE3_WORD','$500 -- $900');
define('PRANGE3_MIN',500.00);
define('PRANGE3_MAX',899.99);

define('PRANGE4_WORD','$900 -- $1400');
define('PRANGE4_MIN',900.00);
define('PRANGE4_MAX',1399.99);

define('PRANGE5_WORD','Above $1400');
define('PRANGE5_MIN',1400.00);
define('PRANGE5_MAX',MAX_PRICE);

define('SHOW_CATEGORIES',true);
define('SHOW_ATTRIBUTES',true);
define('SHOW_PRICE_RANGE',true);
define('SHOW_AVAILABLE',true);
define('SHOW_SORT',true);
10 Aug 2010, 10:03 PM
#99
jabbawest avatar

jabbawest

Zen Follower

Join Date:
Oct 2009
Location:
Texas
Posts:
197
Plugin Contributions:
0

Re: product filter module addon

Back to fiddling with this again and I've come to the conclusion that it won't give search results based on products that are priced by attributes.

I really like this module and hope that someone has figured it out or has an alternative similar to this that will give results based on ALL attributes.

18 Sep 2010, 10:10 PM
#100
xzaqus avatar

xzaqus

New Zenner

Join Date:
Sep 2010
Posts:
10
Plugin Contributions:
0

Re: product filter module addon

Hi,
I got the filter to work on my test site. It filters the results by color/ size/ price separately. It also sorts if selected price + color or price + size. It does not work with color + size yet. I will try to get it to work. But this was my first attempt at looking at php (i am not a coder, but I understand sql).
I made changes to header_php.php (updated file below)
(BTW, I wont be able to answer anything as I still dont know php or any other language)

<?php /** * header_php.php * *Zen Cart product filter module *Johnny Ye, Oct 2007 * update by Jan Cabicar, Apr 2009 * update by xzaqus, Sep 2010 */ require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php')); $error = false; $missing_one_input = false; if (isset($_GET['categories_id']) && !is_numeric($_GET['categories_id'])){ $error = true; $messageStack->add_session('filter', ERROR_AT_LEAST_ONE_INPUT); } else { $categories_id =''; } $available = 'yes'; $option_ids = array(); $option_values = array(); foreach($_GET as $key => $value){ if(substr_count($key,'options')>0) { $option_ids[sizeof($option_ids)] = str_replace('options_','',$key); $option_values[sizeof($option_values)] = $value; } } if (isset($_GET['categories_id'])) { $categories_id = $_GET['categories_id']; } if (isset($_GET['price_range'])) { $price_range = $_GET['price_range']; } if (isset($_GET['available'])) { $available = $_GET['available']; } if (isset($_GET['sort'])) { $sort = $_GET['sort']; } $price_check_error = false; if (zen_not_null($pfrom)) { if (!settype($pfrom, 'float')) { $error = true; $price_check_error = true; $messageStack->add_session('filter', ERROR_PRICE_FROM_MUST_BE_NUM); } } $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE); asort($define_list); $column_list = array(); reset($define_list); while (list($column, $value) = each($define_list)) { if ($value) $column_list[] = $column; } $select_column_list = ''; for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { if (($column_list[$col] == 'PRODUCT_LIST_NAME') || ($column_list[$col] == 'PRODUCT_LIST_PRICE')) { continue; } if (zen_not_null($select_column_list)) { $select_column_list .= ', '; } switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model'; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name'; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity'; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image'; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight'; break; } } // always add quantity regardless of whether or not it is in the listing for add to cart buttons if (PRODUCT_LIST_QUANTITY < 1) { if (empty($select_column_list)) { $select_column_list .= ' p.products_quantity '; } else { $select_column_list .= ', p.products_quantity '; } } if (zen_not_null($select_column_list)) { $select_column_list .= ', '; } // Notifier Point $select_str = "SELECT DISTINCT " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_price_sorter, p.products_qty_box_status "; $from_str = " FROM " . TABLE_PRODUCTS ." p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS . " po , " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov "; $order_str=''; $listing_sql = $select_str . $from_str . $where_str . $order_str; $listing_sql = "select DISTINCT "; $listing_sql .= "p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, p.products_price_sorter, p.products_qty_box_status "; $where_str = " WHERE (p.products_status = 1 "; $enable_price_filter = true; switch($price_range){ case 0: $pfrom = MIN_PRICE; $pto = MAX_PRICE; break; case 1: $pfrom = PRANGE1_MIN; $pto = PRANGE1_MAX; break; case 2: $pfrom = PRANGE2_MIN; $pto = PRANGE2_MAX; break; case 3: $pfrom = PRANGE3_MIN; $pto = PRANGE3_MAX; break; case 4: $pfrom = PRANGE4_MIN; $pto = PRANGE4_MAX; break; case 5: $pfrom = PRANGE5_MIN; $pto = PRANGE5_MAX; break; } if(SHOW_SORT){ switch($sort){ case 0: $order_str = " order by p.products_date_added DESC, p.products_date_available DESC, products_price ASC "; break; case 1: $order_str = " order by p.products_date_added ASC, p.products_date_available ASC, products_price ASC "; break; case 2: $order_str = " order by p.products_price ASC, p.products_date_added DESC, p.products_date_available DESC "; break; case 3: $order_str = " order by products_price DESC, p.products_date_added DESC, p.products_date_available DESC "; break; $order_str = " order by p.products_date_added DESC, p.products_date_available DESC, products_price ASC "; } } $enable_attribute_filter = true ; if(sizeof($option_ids)>0){ for($i=0;$i<sizeof($option_ids);$i++){ if(!(empty($option_values[$i]))) { $where_str .= " AND pa.options_id = ".$option_ids[$i]; $where_str .= " AND pa.options_values_id = ".$option_values[$i]; } } } if($enable_attribute_filter){ $where_str .= " AND p.products_id = pa.products_id "; } if($categories_id !=''){ $where_str .=" AND p2c.categories_id = ".$categories_id; } if($enable_price_filter){ $where_str .= " AND p.products_price >= ".$pfrom; $where_str .= " AND p.products_price <= ".$pto; } if($available=='yes'){ $where_str .= " AND p.products_quantity > 0 "; } $where_str .=" AND p.products_id = pd.products_id"; $where_str .=" AND p.products_id = p2c.products_id) "; $listing_sql .= $from_str; $listing_sql .= $where_str; $listing_sql .= $order_str; $listing_sql //$breadcrumb->add('title'); // This should be last line of the script: ?>