Forums / Addon Sideboxes / Dynamic Filter [Support Thread]

Dynamic Filter [Support Thread]

Views: 653,483

Results 21 to 40 of 809
24 Apr 2012, 10:51 PM
#21
sph avatar

sph

Totally Zenned

Join Date:
Jan 2006
Posts:
1,556
Plugin Contributions:
0

Dynamic Filter [Support Thread]

I couldn't figure out how to Exclude Options, but your patch seems to have worked!

http://www.prom-mart.com/demo-1/dvd-movies-action-c-3_10.html

Thanks!

sph

PS: Should this thread by your official support thread for this mod?

Steve
prommart.com

24 Apr 2012, 11:13 PM
#22
sph avatar

sph

Totally Zenned

Join Date:
Jan 2006
Posts:
1,556
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Damian,

Your Dynamic Filter is even better/more powerful than I originally thought. It can also sort by Features, so everything does not have to be a selectable attribute.

http://www.prom-mart.com/demo-1/sale-new-price-set-100-c-50_46.html

After six years, there is still alot I can learn about zencart.

Steve
prommart.com

25 Apr 2012, 9:29 AM
#23
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

This is a great mod. I do have 1 problem. I'm building a store that will sell big/tall mens clothing. I wanted a filter to mainly filter by size. So I added size as one of the attributes. I went to shirts and I wanted to filter out everything but a 7X size. It didn't filter. It still showed all the shirts in the catagory after I chose 7X. I sure hope I can get this working. Any help would be much appreciated. I am using version 1.5

Thanks

27 Apr 2012, 8:14 PM
#24
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

This is a great mod. I do have 1 problem. I'm building a store that will sell big/tall mens clothing. I wanted a filter to mainly filter by size. So I added size as one of the attributes. I went to shirts and I wanted to filter out everything but a 7X size. It didn't filter. It still showed all the shirts in the category after I chose 7X. I sure hope I can get this working. Any help would be much appreciated. I am using version 1.5

P.S. I did reply to another thread regarding Dynamic Filter 1.0, didn't know there was another thread about the filters not working. Sorry for the multiple posts.

27 Apr 2012, 8:16 PM
#25
daviator avatar

daviator

New Zenner

Join Date:
Mar 2012
Posts:
26
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Did you download the latest version that came just this past week?

27 Apr 2012, 8:25 PM
#26
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Daviator:

Did you download the latest version that came just this past week?

Yes, I just downloaded it a couple days ago. It's the newest, latest version. Just can't get it to filter. I tried it on shits with the larger sizes (7X+) and it doesn't filter anything.

27 Apr 2012, 8:42 PM
#27
daviator avatar

daviator

New Zenner

Join Date:
Mar 2012
Posts:
26
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Can I get the URL to you site? (I'm a beginner too but a second set of eyes couldn't hurt)

27 Apr 2012, 9:04 PM
#28
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Daviator:

Can I get the URL to you site? (I'm a beginner too but a second set of eyes couldn't hurt)

http://www.bigandtallwarehouse.com (I have to turn it on, it's set for off (maintenance) )

27 Apr 2012, 11:06 PM
#29
daviator avatar

daviator

New Zenner

Join Date:
Mar 2012
Posts:
26
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

can you turn on please?

30 Apr 2012, 1:05 PM
#30
sonic_x avatar

sonic_x

New Zenner

Join Date:
Apr 2012
Posts:
3
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

damiantaylor:

SPH, try this amendment to 'new files\includes\templates\YOUR_TEMPLATE\sideboxes\tpl_dynamic_filter.php' around line 250.
The lines you're adding are 'if ($attributes->RecordCount() > 0) {' and it's associated closing brace '}' near the end of the snippet.....

/start attribute link/check boxes*******/

if(count($filteredProducts) > 0){
	// Below line counts up all quantities of each item. e.g. if a glove is available in Small and Medium, quantity = 2.
	//$attributes = $db->Execute("SELECT po.products_options_name, pov.products_options_values_name, count( p2as.quantity ) as quantity" .
	$attributes = $db->Execute("SELECT count(DISTINCT p2a.products_id) as quantity, po.products_options_name, pov.products_options_values_name," .
	 " SUM(IF(p2a.products_id IN(" . implode(',', $filteredProducts) . "), 1, 0)) as flag" .
	 " FROM " . TABLE_PRODUCTS_ATTRIBUTES . " p2a ".
	 " JOIN " . TABLE_PRODUCTS_OPTIONS . " po ON p2a.options_id = po.products_options_id".
	 " JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES ." pov ON p2a.options_values_id = pov.products_options_values_id".
	 (defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " p2as ON p2a.products_id = p2as.products_id AND p2as.stock_attributes LIKE CONCAT('%', p2a.products_attributes_id, '%')" : "") .
	 " WHERE p2a.products_id IN (" . implode(',', $unfilteredProducts) . ")" .
	 (FILTER_OPTIONS_INCLUDE != '' ? " AND p2a.options_id IN (" . FILTER_OPTIONS_INCLUDE . ")" : '') .
	 (FILTER_OPTIONS_EXCLUDE != '' ? " AND p2a.options_id NOT IN (" . FILTER_OPTIONS_EXCLUDE . ")" : '') .
	 (defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " AND p2as.quantity > 0" : "") .
	 " GROUP BY po.products_options_name, pov.products_options_values_name" .
	 " ORDER BY po.products_options_name, pov.products_options_values_sort_order");

	if ($attributes->RecordCount() > 0) {
	$savName = '';
	$savValue = '';
	while (!$attributes->EOF) {
	// output if option name changes!!!
		if ($attributes->fields['products_options_name'] != $savName) {
			$options_array = array();
			if ($savName != "") {
				$content .= '<hr width="90%" size="0" />';
				$content .= '<div><div class="dFilter"><p class="dFilterHeading">' . DYNAMIC_FILTER_TEXT_PREFIX . htmlspecialchars(html_entity_decode($savName, ENT_QUOTES)) . DYNAMIC_FILTER_TEXT_SUFFIX . '</p>';
				if (isset($_GET[$group]) && array_filter($_GET[$group])) $content .= '<div class="dFilterClear"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array($group)), 'NONSSL') . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'clear_filter.png', DYNAMIC_FILTER_BUTTON_CLEAR_FILTER_ALT) . '</a></div>';
				if (strtok(FILTER_STYLE, " ") == 'Dropdown') $content .= '<select name="' . $group . '[]" class="dFilterDrop"' . (FILTER_STYLE == 'Dropdown - Single' ? ' onchange="this.form.submit();"' : '') . '>' . '<option value=""' . (!isset($_GET[$group]) || !array_filter($_GET[$group]) ? ' selected="selected"' : '') . '>' . $dropdownDefault . '</option>';
				else $content .= '<ul' . ($attrCount > FILTER_MAX_OPTIONS ? (FILTER_OPTIONS_STYLE == 'Scroll' ? ' class="dFilterScroll">' : ' class="dFilterExpand">') : '>');
				$content .= $filters;
				if (strtok(FILTER_STYLE, " ") == 'Dropdown') $content .= '</select>';
				else $content .= '</ul>';
				if (FILTER_OPTIONS_STYLE == 'Expand' && $attrCount > FILTER_MAX_OPTIONS) $content .= '<a class="dFilterToggle" href="#">More' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'arrow_more.gif', 'More', '', '', 'class="dFilterToggleImg"') . '</a>';
				$content .= '</div></div>';
			}

			$group = DYNAMIC_FILTER_PREFIX . str_replace(' ', '', $attributes->fields['products_options_name']);
			$resetParms[] = $group;
			$parameters = zen_get_all_get_params();
			$dropdownDefault = str_replace('%n', $attributes->fields['products_options_name'], DYNAMIC_FILTER_DROPDOWN_DEFAULT);
			$filters = '';
			$attrCount = 0;
		}
				
		if ($attributes->fields['products_options_values_name'] != $savValue) {
			if (isset($_GET[$group]) && in_array($attributes->fields['products_options_values_name'],$_GET[$group])) $linkClass = 'selected';
			else if (isset($_GET[$group]) && array_filter($_GET[$group]) && !in_array($attributes->fields['products_options_values_name'],$_GET[$group]) || $attributes->fields['flag'] == 0) $linkClass = 'disabled';
			//else if ($attributes->fields['flag'] == 0) $linkClass = 'disabled';
			else $linkClass = 'enabled';
			
			$onClick = '';
			if (FILTER_GOOGLE_TRACKING != 'No') $onClick .= $trackingStart . '\'filterAction\', \'' . ($linkClass != 'selected' ? 'addFilter' : 'removeFilter') . '\', \'' . $pageName . ';' . $attributes->fields['products_options_name'] . '=' . htmlspecialchars(html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES)) . '\'' . $trackingEnd;
			if (FILTER_STYLE == 'Checkbox - Single') $onClick .= ' this.form.submit();';

			if (FILTER_METHOD != 'Hidden' || $linkClass != 'disabled') {
				$hrefLink = $group . '[]=' . rawurlencode($attributes->fields['products_options_values_name']);
				switch(strtok(FILTER_STYLE, " ")) {
				case 'Checkbox':
					$filters .= '<li class="dFilterLink">' . zen_draw_checkbox_field($group . '[]', $attributes->fields['products_options_values_name'], (isset($_GET[$group]) && in_array($attributes->fields['products_options_values_name'],$_GET[$group]) ? true : false), ($linkClass == 'disabled' ? 'disabled="disabled"' : '') . ($onClick != '' && FILTER_STYLE == 'Checkbox - Single' ? ' onclick="' . $onClick . '"' : '')) . htmlspecialchars(html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES)) . '</li>';
					break;
				case 'Link':
					$filters .= '<li class="dFilterLink"><a class="' . $linkClass . '"' . ($linkClass != 'disabled' ? ' rel="nofollow" href="' . zen_href_link($_GET['main_page'], ($linkClass != 'selected' ? $parameters . $hrefLink : str_replace(array($hrefLink,'&'.$hrefLink), array("",""), $parameters)), 'NONSSL') . '"' . ($onClick != '' ? ' onclick="' . $onClick . '"' : '') : '') . ' >' . htmlspecialchars(html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES)) . '</a></li>';
					break;
				case 'Dropdown':
					$filters .= '<option value="' . htmlspecialchars(html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES)) . '"' . ($linkClass == 'selected' ? ' selected="selected"' : '') . ($linkClass == 'disabled' ? ' disabled="disabled"' : '') . ($onClick != '' && FILTER_STYLE == 'Dropdown - Single' ? ' onclick="' . $onClick . '"' : '') . ' >' .  $attributes->fields['products_options_values_name'] . '</option>';
					break;
				}
			++$attrCount;
			}
		}
		$savValue = $attributes->fields['products_options_values_name'];
		$savName = $attributes->fields['products_options_name'];
	$attributes->MoveNext();
	}
	if ($savName != "") {
		$content .= '<hr width="90%" size="0" />';
		$content .= '<div><div class="dFilter"><p class="dFilterHeading">' . DYNAMIC_FILTER_TEXT_PREFIX . htmlspecialchars(html_entity_decode($savName, ENT_QUOTES)) . DYNAMIC_FILTER_TEXT_SUFFIX . '</p>';
		if (isset($_GET[$group]) && array_filter($_GET[$group])) $content .= '<div class="dFilterClear"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array($group)), 'NONSSL') . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'clear_filter.png', DYNAMIC_FILTER_BUTTON_CLEAR_FILTER_ALT) . '</a></div>';
		if (strtok(FILTER_STYLE, " ") == 'Dropdown') $content .= '<select name="' . $group . '[]" class="dFilterDrop"' . (FILTER_STYLE == 'Dropdown - Single' ? ' onchange="this.form.submit();"' : '') . '>' . '<option value=""' . (!isset($_GET[$group]) || !array_filter($_GET[$group]) ? ' selected="selected"' : '') . '>' . $dropdownDefault . '</option>';
		else $content .= '<ul' . ($attrCount > FILTER_MAX_OPTIONS ? (FILTER_OPTIONS_STYLE == 'Scroll' ? ' class="dFilterScroll">' : ' class="dFilterExpand">') : '>');
		$content .= $filters;
	}
	if (strtok(FILTER_STYLE, " ") == 'Dropdown') $content .= '</select>';
	else $content .= '</ul>';
	if (FILTER_OPTIONS_STYLE == 'Expand' && $attrCount > FILTER_MAX_OPTIONS) $content .= '<a class="dFilterToggle" href="#">More' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'arrow_more.gif', 'More', '', '', 'class="dFilterToggleImg"') . '</a>';
	$content .= '</div></div>';
	}
}

/end attribute link/check boxes*******/

> 
> Can you let me know if it works for you?

Im having the exact same problem the sideboxes after the dynamic filter box are mis aligned but when I add those lines to the end of the snippet the pages with dynamic pages sidebox fails to load, 

what am I doing wrong?
1 May 2012, 11:40 PM
#31
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

After I installed this mod and it overridden the default_filter.php in my includes/index_filters/MYTEMPLATE/ folder with the new file, I get an SQL error when I select a catagory, like Jeans for instance. It says 'WARNING: An Error occurred, please refresh the page and try again.' I go to the cache to see the error and this is what it says:

PHP Fatal error: 1054:Unknown column 'm.manufacturers_name' in 'field list' :: SELECT DISTINCT p.products_image, pd.products_name, m.manufacturers_name, p.products_model, p.products_quantity, p.products_id, p.products_type, p.master_categories_id,
p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1,
s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status =1, s.specials_new_products_price,
p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping,
p.products_qty_box_status FROM products p LEFT JOIN specials s on p.products_id = s.products_id LEFT JOIN products_description pd on p.products_id = pd.products_id JOIN products_to_categories p2c on p.products_id = p2c.products_id JOIN products_attributes p2a on p.products_id = p2a.products_id JOIN products_options po on p2a.options_id = po.products_options_id JOIN products_options_values pov on p2a.options_values_id = pov.products_options_values_id WHERE p.products_status = 1
and pd.language_id = '1'
and p2c.categories_id = '17' GROUP BY p.products_id HAVING ( FIND_IN_SET("Sizes34x36", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), pov.products_options_values_name)))) order by p.products_sort_order, pd.products_name in /homepages/29/d402403078/htdocs/BIGANDTALLWAREHOUSE/includes/classes/db/mysql/query_factory.php on line 101

If I go back to the original default_filter.php file, it works fine. Any thoughts? Any help would be great, I would really love to use this mod. Thanks for your help.

2 May 2012, 2:44 PM
#33
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Thanks, that seemed to fix the SQL problem. It looks like it's working but I have a few problems. I tried it on my polo shirt category and I wanted to see if it would filter out all but the 10X sizes (I have 2 style shirts in that size) It filters, but it's only showing 1 of the 2 shirts. It says: 'Displaying 1 to 2 (of 2 products)' which I think it means 1 OF 2 (of 2 products) Not sure why it won't show the other style, which does have the same size available. I'll turn my store on so you can see. It also didn't display a jean I have available in a size 80x32. It just shows a blank screen with 'Displaying 1 to 2 (of 2 products)'. Thanks again for all your help, I really appreciate it:smile:

http://www.bigandtallwarehouse.com

2 May 2012, 5:40 PM
#34
damiantaylor avatar

damiantaylor

Zen Follower

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

Re: Dynamic Filter [Support Thread]

jimproz, I don't know why that particular size is resulting in no products returned.
Can you add the following 'die' statement (around line 25) to file 'new files/includes/templates/YOUR_TEMPLATE/sideboxes/tpl_dynamic_filter.php'

die($listing_sql);
// draw filter form
   	$content = '';
	$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
	$content .= zen_draw_form('product_filter_form','', 'get');

Once you've done that, go directly to this link http://www.bigandtallwarehouse.com/Jeans?sort=0&fltSizes[]=80x32
That should just show you a SQL select statement on the screen.
Can you copy that statement and paste it here so I can take a look?

Once you've done that, remove the 'die' statement from the file otherwise you won't be able to see any products in your store.

2 May 2012, 5:46 PM
#35
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

SELECT DISTINCT p.products_id, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status =1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status FROM products p LEFT JOIN specials s on p.products_id = s.products_id LEFT JOIN products_description pd on p.products_id = pd.products_id LEFT JOIN manufacturers m on p.manufacturers_id = m.manufacturers_id JOIN products_to_categories p2c on p.products_id = p2c.products_id WHERE p.products_status = 1 and pd.language_id = '1' and p2c.categories_id = '17' GROUP BY p.products_id

2 May 2012, 5:54 PM
#36
damiantaylor avatar

damiantaylor

Zen Follower

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

Re: Dynamic Filter [Support Thread]

Sorry, it looks like clicking the link drops the '[]=80x32' from the url.
Can you try again but rather than clicking the link, copy and paste this in to your browser address bar

http://www.bigandtallwarehouse.com/Jeans?sort=0&fltSizes[]=80x32

thanks

2 May 2012, 5:57 PM
#37
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

damiantaylor:

Sorry, it looks like clicking the link drops the '[]=80x32' from the url.
Can you try again but rather than clicking the link, copy and paste this in to your browser address bar

http://www.bigandtallwarehouse.com/Jeans?sort=0&fltSizes[]=80x32

> 
> thanks
Sure, here it is

SELECT DISTINCT p.products_id, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status =1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status FROM products p LEFT JOIN specials s on p.products_id = s.products_id LEFT JOIN products_description pd on p.products_id = pd.products_id LEFT JOIN manufacturers m on p.manufacturers_id = m.manufacturers_id JOIN products_to_categories p2c on p.products_id = p2c.products_id JOIN products_attributes p2a on p.products_id = p2a.products_id JOIN products_options po on p2a.options_id = po.products_options_id JOIN products_options_values pov on p2a.options_values_id = pov.products_options_values_id WHERE p.products_status = 1 and pd.language_id = '1' and p2c.categories_id = '17' GROUP BY p.products_id HAVING ( FIND_IN_SET("Sizes80x32", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), pov.products_options_values_name))))

Thanks for helping me with this
2 May 2012, 6:19 PM
#38
damiantaylor avatar

damiantaylor

Zen Follower

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

Re: Dynamic Filter [Support Thread]

The SQL seems fine to me.
It's weird, if you filter on 78x32 which should just show the Stonewash Stretch Jean & Black Stretch Denim Jean you get no products.
If you filter on 36x36 you get 4 items including Stonewash Stretch Jean & Black Stretch Denim Jean so that rules out anything strange with those 2 items.
I'm at a real loss to explain it and I can't think of anything else I can do from here.
All I can suggest for the time being is log in to your web server and go to phpMyAdmin then paste the SQL in to the SQL box and see if it runs ok. It should return 2 rows.
If it doesn't you could try playing with the SQL to see if you can see what is going wrong. Maybe try removing the HAVING section to see if that gives you any results?
The only other thing I can suggest, although it's a long shot is removing the spaces around the bracket in 'HAVING ( FIND_IN_SET'. Sometimes SQL doesn't like spaces.

Sorry I can't be more help at the moment. I'll have a think and see if I can come up with anything.....

2 May 2012, 6:25 PM
#39
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Thanks for looking into this. I really appreciate it. I'll do that and see what it comes up with. Yeah, it's weird, it filters ok with some values, but others, no go. I'm completely stumped myself. I'll try your suggestions. Thanks again.

2 May 2012, 6:46 PM
#40
jimproz avatar

jimproz

New Zenner

Join Date:
Mar 2008
Posts:
30
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

I just ran the SQL like you suggested and it did come back with 2 products, like it should. So now I'm really confused:huh: