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

product filter module addon

Views: 81,446

Results 41 to 60 of 169
19 May 2009, 4:40 AM
#41
kyli51 avatar

kyli51

New Zenner

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

product filter module addon

hi all,
thanks for the reply...yes i do understand the issue...the thing is i already tried..and it works...but only half of it..means i obviously dont have the error anymore but i can't still filter only by price...otherwise i have all the result..no matter the value..

any other ideas ?

8 Jun 2009, 1:08 AM
#42
pelasgos avatar

pelasgos

New Zenner

Join Date:
Dec 2006
Location:
Athens - Greece
Posts:
71
Plugin Contributions:
0

Re: product filter module addon

The same for me..
Every price-range value that I select, the filter shows all products as a result.
Any ideas?

14 Jun 2009, 12:01 AM
#43
dropbop avatar

dropbop

Zen Follower

Join Date:
Apr 2008
Location:
Athlone, Ireland
Posts:
177
Plugin Contributions:
1

Re: product filter module addon

The solution is to (probably) remove the "zs_" prefix on the table "zs_products_attributes" in the SQL statement. If you know how to view your SQL tables, view them and look for the correct table name. My tables do not have a "zs_" prefix, but your tables may have another prefix.

Go to:
"includes/modules/pages/product_filter_result/header_php.php"

Change the line:
<code>$where_str .= " AND ((pa.products_id In (SELECT pa.products_id FROM zs_products_attributes pa WHERE ("; </code>

To:
<code>$where_str .= " AND ((pa.products_id In (SELECT pa.products_id FROM products_attributes pa WHERE ("; </code>

OR change it to the product_attribute table name in your system.

Hope it works and you understand what I'm talking about...

Perfect - cheers for that, Worked perfectly!

Such a simple thing to miss.

And for people who installed Zen using fantastico.. you may have to change the table prefix to 'zen_' as fantastico can add it automaticly to your tables.

To find out what the table prefix is.. open cpanel

http://www.yourdomain.com/cpanel

scroll down to phpMyAdmin and click it.

Find the database your zencart is using.

you will see at the start of each table a prefex ie: 'zen_'

copy the prefix and change the prefix in the header_php.php supplied with this addon

Find this line

$where_str .= " AND ((pa.products_id In (SELECT pa.products_id FROM zs_products_attributes pa WHERE (";

and change zs_products_attributes to zen_products_attributes (or what ever your database prefix is)

Hope this is of some help....

DB

14 Jun 2009, 12:20 AM
#44
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: product filter module addon

Or just use the much simpler universal fix i posted earlier ...

18 Jun 2009, 7:13 PM
#45
biketuna avatar

biketuna

New Zenner

Join Date:
Jun 2009
Posts:
17
Plugin Contributions:
0

Re: product filter module addon

Can anyone tell me how to install this? I cant seem to get it working....

thanks

7 Jul 2009, 6:38 PM
#46
pajur avatar

pajur

New Zenner

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

Re: product filter module addon

Hi, I have the same problem as some other people here. Filter is not working at all. No error message, it just will not get any results, no matter what you set as a condition.

7 Jul 2009, 6:42 PM
#47
biketuna avatar

biketuna

New Zenner

Join Date:
Jun 2009
Posts:
17
Plugin Contributions:
0

Re: product filter module addon

Hi all,

I'm still having problems getting this working, I've got a lot further than before from following all the fixes on here, but have 3 remaining issues

1 - How do you limit the search box so it only searches by one specific attribute?

2 - The results are not showing anything, and I believe this is because it is not searching subcategories

3 - The order of the attribute options are not in the same order as the default sort order, instead they are in the order that they were entered into the database.

Any help would be appreciated

7 Jul 2009, 7:15 PM
#48
pajur avatar

pajur

New Zenner

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

Re: product filter module addon

2 - results are not showing anything - In my case, it does not matter if products are in categories or subcategories. No errors, but also no results at all.

9 Jul 2009, 6:56 PM
#49
biketuna avatar

biketuna

New Zenner

Join Date:
Jun 2009
Posts:
17
Plugin Contributions:
0

Re: product filter module addon

2 I have now done further testing and found it not working regardless of subcategory

Please help!!! I dont want to launch the site without this functionality!!!

20 Jul 2009, 3:53 PM
#50
frumfell avatar

frumfell

New Zenner

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

Re: product filter module addon

hi, i would like to ask you about some problem with filter module addon. i have installed last version 0.7 where are files to czech version, beside english.
i have changed chech files to polish, but i have this kind of problem, that filter see all attributes doubled, regardless which language version is on. i mean, on polish version for example atributes are doubled, and in both, you can choose both attribute values.
im not sure, but if you can have a look
malowanaszafa.pl
if there is any one who installed this addon in multi language sites? and how to solve this problem?
my zencart version 1.3.8
with polish language module from zencart.com.pl

i have one idea, what can couse this problem. when i add new option value to option name in option value manager in admin , they seem to be doubled ?

21 Jul 2009, 10:55 AM
#51
frumfell avatar

frumfell

New Zenner

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

Re: product filter module addon

i have read trough all php files in the shop categorry which included TABLE_PRODUCTS_OPTIONS words, and i think they have got always kind of indicator:

AND popt.language_id = :languageID
AND poval.language_id = :languageID " . $options_order_by;

what as i guess narrow question to database only to results in language of session.

as i read trough files of this addon, i havent found any indicators like that in them, so maybe thats the reason why addon doesnt regonize languages of attributes?

i have totally no knowledge about php, so probably if someone know how and where to put these indicators to addon files, it will work well on multilingual sites, i will be thankfull

and as i notice, files from shop use these shortcuts popt for product option and poval for product option value, but files in addon use shortcuts like po and pov, but probably it doesnt make any diference, right?

21 Jul 2009, 4:07 PM
#52
frumfell avatar

frumfell

New Zenner

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

Re: product filter module addon

hi, so finaly i made it, by comparing how it looks like in other files - actually thats my first contact with php, so if someone can take a look if it is corect, but whats important for me, it work.
so in addon file includes/templates/TEMPLATE/sideboxes/tpl_product_filter.php in line 35 where was

$option_names = $db->Execute("SELECT products_options_id,products_options_name FROM ". TABLE_PRODUCTS_OPTIONS);

i changed to

$option_names = $db->Execute("SELECT products_options_id,products_options_name FROM ". TABLE_PRODUCTS_OPTIONS." po where po.language_id = ".$_SESSION['languages_id']);

and in line 38 where was

$option_names_values = $db->Execute("select pov.products_options_values_id, pov.products_options_values_name from ". TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS." povp,".TABLE_PRODUCTS_OPTIONS_VALUES." pov where povp.products_options_values_id = pov.products_options_values_id AND povp.products_options_id =".$option_names->fields['products_options_id']);

i changed to

$option_names_values = $db->Execute("select pov.products_options_values_id, pov.products_options_values_name from ". TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS." povp,".TABLE_PRODUCTS_OPTIONS_VALUES." pov where povp.products_options_values_id = pov.products_options_values_id AND pov.language_id = '" . (int)$_SESSION['languages_id'] . "' AND povp.products_options_id =".$option_names->fields['products_options_id']);

efect is such, that in case of multilingual shops filter box shows only product attributes from language which is already in use by customer. probably it was easy to find out this, but i send these changes for people like me, who dont know php.
by the way, i got question, if someone can explain me how to make this filter searching by only one attribute, like size?
probably its gonna be as well easy for someone who know php
will be thankfull

14 Aug 2009, 2:09 PM
#53
louis avatar

louis

Zen Follower

Join Date:
Jul 2006
Location:
Johannesburg
Posts:
408
Plugin Contributions:
0

Re: product filter module addon

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.

18 Aug 2009, 9:54 PM
#54
wt05 avatar

wt05

New Zenner

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

Re: product filter module addon

Has anyone fixed the problem of filtering subcategories?

For example:

All Categories - Sub -- Subsub --- Subsubsub

The filter only works in "All Categories" and "Subsubsub" - only if Subsubsub contained products.

Sub and Subsub will not filter if no product listed in these subcategories.

30 Aug 2009, 11:13 AM
#55
susumu avatar

susumu

New Zenner

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

Re: product filter module addon

how can I use this module in zencart ver 1.3.0.2?

4 Sep 2009, 11:13 PM
#56
kburner avatar

kburner

Totally Zenned

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

Re: product filter module addon

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

8 Sep 2009, 5:08 PM
#57
infocom avatar

infocom

Zen Follower

Join Date:
Jul 2006
Location:
Cardiff, Wales
Posts:
308
Plugin Contributions:
0

Re: product filter module addon

Excellent Mod... so many sites have this feature so great to see it on Zencart... Just a couple of issues I had though, one is already reported but not fixed...

  1. In header_php.php line 146 you need to change reference to zs_products_attributes to TABLE_PRODUCTS_ATTRIBUTES to make sure this works with any named table

from

$where_str .= " AND ((pa.products_id In (SELECT pa.products_id FROM zs_products_attributes pa WHERE (";
to

$where_str .= " AND ((pa.products_id In (SELECT pa.products_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa WHERE (";
  1. This did not work for me right away, it did not filter. It took me a while to see in your code you have:
    $enable_attribute_filter = false ;
    $enable_price_filter = false ;

I could not see in Admin where to turn this on, the instructions say nothing. So I had to change the above to true so it would work.

Is this correct??? If its in Admin where is it, if you have to change the above can you add it to instructions?

Apart from that is working great and is a good little mod. Thanks.

8 Sep 2009, 6:08 PM
#58
davowave avatar

davowave

New Zenner

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

Re: product filter module addon

Hey there,

I've been trying to get this mod working for the last couple of days. I really like what it does (despite the fact I haven't got it quite working perfectly yet!) but I'd like to have a go at adapting the code slightly for my own needs. The problem is I'm having a bit of trouble figuring out exactly whats happening in the includes\modules\pages\product_filter_result\header_php.php.

I think I can understand all the other files associated with this mod and what they are meant to be doing but the header_php.php has me a bit confused. I don't suppose anyone who knows would fancy adding comments to the code?

thanks

8 Sep 2009, 6:17 PM
#59
barricades avatar

barricades

Inactive

Join Date:
May 2007
Posts:
150
Plugin Contributions:
0

Re: product filter module addon

Hi there, I have this mod installed and it looks like it works ok. The only problem is that I had SimpleSEO-URL installed and I had to turn it off to make this mod work. Is there anyway to have the two mods working together? What would be required? I'd pay someone if they could do this for me or even help me to do it myself

cheers

21 Sep 2009, 11:55 PM
#60
atmpartmart avatar

atmpartmart

New Zenner

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

Re: product filter module addon

Well, here's a new one that nobody has posted about. Strange because I know the field "master_categories_id" does exist in the table "zen_products" (this is the correct table prefix in my installation).

If anybody can point me in the right direction, I'd greatly appreciate it. Here is the error below. Doesn't matter what category you search or price range, it always is a problme with "p.master_categories_id"...

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_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 p2c.categories_id = 700 AND p.products_price >= 0 AND p.products_price <= 1000000 AND p.products_quantity > 0 AND p.products_id = pd.products_id AND p.products_id = p2c.products_id) ]