Zen Cart Logo
Forums / Addon Sideboxes / Dynamic Filter [Support Thread]

Dynamic Filter [Support Thread]

Views: 652,533

Results 481 to 500 of 809
1 Oct 2014, 3:03 PM
#481
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Dynamic Filter [Support Thread]

RodG:

This may help (changes in blue) :

// File /modules/custom/dynamic_filter.php

/ Price Range/Attribute filter
$manufacturerGroup = str_replace(' ', '', DYNAMIC_FILTER_MANUFACTURER_GROUP);
$categoryGroup = str_replace(' ', '', DYNAMIC_FILTER_CATEGORY_GROUP);
$priceGroup = str_replace(' ', '', DYNAMIC_FILTER_PRICE_GROUP);
$prvKey = '';
$prvHaving = '';
$filter = '';
$having = '';
$filter_attr = false;

reset($_GET);
while(list($key, $value) = each ($_GET)) {
// if(!is_array($value)) { // skip if not array // RodG

if(substr($key,0,strlen(DYNAMIC_FILTER_PREFIX)) == DYNAMIC_FILTER_PREFIX && array_filter($value)) {
  $key = str_replace(DYNAMIC_FILTER_PREFIX, '', $key);
  foreach ($value as $value) {
    
      if($key == $manufacturerGroup || $key == $categoryGroup || $key == $priceGroup) {
      if($key != $prvKey) {
        if($prvKey != '') {
          $filter .= ') and (';
        } else {
          $filter .= ' and (';
        }
      } else {
        $filter .= ' or ';
      }
      }
    // manufacturer
    if($key == $manufacturerGroup) {
      $filter .= "m.manufacturers_id = '" . (int)$value . "'";
      $prvKey = $key;
    // category
    } else if($key == $categoryGroup) {
      $filter .= "p2c.categories_id = '" . (int)$value . "'";
      $prvKey = $key;
    // price range
    } else if($key == $priceGroup) {
      list($low,$high) = explode("--",$value);
      //          Updated to include GST by RodG

$filter .= 'p.products_price_sorter>=' . ($low - ($low / 11)) . ' and ' . 'p.products_price_sorter<=' . ($high - ($high / 11));
// $filter .= 'p.products_price_sorter>=' . $low . ' and ' . 'p.products_price_sorter<=' . $high; // original code //
$prvKey = $key;
// attributes
} else {
if($key != $prvHaving) {
if($prvHaving != '') {
$having .= ') and (';
} else {
$having .= 'HAVING (';
}
} else {
$having .= ' or ';
}
$having .= ' FIND_IN_SET("' . $key . $value . '", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), pov.products_options_values_name)))';
$filter_attr = true;
$prvHaving = $key;
}
}
}
//}
}
if($filter != '') $filter .= ')';
if($having != '') $having .= ')';
if($filter_attr == true && defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK')) $filter .= ' AND p2as.quantity > 0 AND FIND_IN_SET(p2a.products_attributes_id, p2as.stock_attributes)';


OK, so it isn't going to be exactly what you want. This was a quick n dirty fix I added to a customers site to account for a 10% GST.
It shouldn't be hard to replace these hard coded calculations with variables obtained from the Tax tables though.

Cheers
RodG

Thx, I'll go and test it right away.

2 Oct 2014, 3:33 PM
#482
andreas1211 avatar

andreas1211

New Zenner

Join Date:
Sep 2012
Posts:
27
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Hey guys,

Thanks for the answers!

Would it be possible to set the filter so it searches in subcategories too? For example I have binoculars on my site. Category is binoculars and the subcategories are the brands (Zeiss Leupold etc). So if a customer sets a price range filter in the binoculars category, I want him to get the result of all brands in that price range.

Thanks for the answers in advance!

3 Oct 2014, 6:25 AM
#483
wrickspam avatar

wrickspam

New Zenner

Join Date:
Dec 2011
Location:
Emmen, The Netherlands
Posts:
85
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

please dont push a update without fixing the big problems surrounding this plugin when working with large amounts of attributes...

search through the topic there are a lot of people with this problem!

3 Oct 2014, 7:06 AM
#484
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Dynamic Filter [Support Thread]

wrickspam:

please dont push a update without fixing the big problems surrounding this plugin when working with large amounts of attributes...

search through the topic there are a lot of people with this problem!

I don't think there is a lot that can be done about that. In my opinion, and knowledge, this has to do with the server resources that are available for your site. Large amounts of attribute require large amounts of memory and cpu. But if someone knows a solution for that please help out.

6 Oct 2014, 7:05 PM
#485
eerin avatar

eerin

New Zenner

Join Date:
Oct 2014
Location:
Sydney
Posts:
2
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Hi,

I'm not sure if this is a problem with dynamic filter or not as it was previously working but I have exhausted every possibility I can think of other than contacting my hosting company to see if they have changed anything. On my website https://www.eliterugs.com.au I have had dynamic filter installed for about a month, I had previously tested it and everything was bullet proof. Yesterday I noticed that the sort by price option returns a 403 forbidden error. All the other options work fine in any combination but as soon as you add the price it fails.

I was wondering if anyone had any idea what could be causing this. As far as I can remember all I have worked on in the last couple of days was adding some dynamic remarketing and analytics code and I upgraded my google merchant centre code.

There are no error logs generated by zen cart or my website and I have double checked my database against a backup from a month ago and it still looks the same.

I am open to any any and all suggestions at this stage as I have run out of ideas.

Thanks.

6 Oct 2014, 7:32 PM
#486
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Dynamic Filter [Support Thread]

Eerin:

Hi,

I'm not sure if this is a problem with dynamic filter or not as it was previously working but I have exhausted every possibility I can think of other than contacting my hosting company to see if they have changed anything. On my website www.eliterugs.com.au I have had dynamic filter installed for about a month, I had previously tested it and everything was bullet proof. Yesterday I noticed that the sort by price option returns a 403 forbidden error. All the other options work fine in any combination but as soon as you add the price it fails.

I was wondering if anyone had any idea what could be causing this. As far as I can remember all I have worked on in the last couple of days was adding some dynamic remarketing and analytics code and I upgraded my google merchant centre code.

There are no error logs generated by zen cart or my website and I have double checked my database against a backup from a month ago and it still looks the same.

I am open to any any and all suggestions at this stage as I have run out of ideas.

Thanks.

Haven't seen that error before, but it is quit possible it is caused by this mod. The price filtering has always been buggy.
What happens if you use a different filter style?

6 Oct 2014, 11:51 PM
#487
eerin avatar

eerin

New Zenner

Join Date:
Oct 2014
Location:
Sydney
Posts:
2
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Thanks for the reply, after an extremely long day yesterday looking through all the code and undoing everything that I had worked on over the last 3 days trying to find the problem. I got onto my web host this morning and it turns out they had done a security update and turned on a new mod_security setting (341245) that was blocking this feature. They have now turned it off for me and everything is working perfectly once again. Hopefully this may help someone in the future if they experience a similar issue. The code it's self is still as bullet proof as ever. Thanks.

7 Oct 2014, 7:05 AM
#488
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Dynamic Filter [Support Thread]

Eerin:

Thanks for the reply, after an extremely long day yesterday looking through all the code and undoing everything that I had worked on over the last 3 days trying to find the problem. I got onto my web host this morning and it turns out they had done a security update and turned on a new mod_security setting (341245) that was blocking this feature. They have now turned it off for me and everything is working perfectly once again. Hopefully this may help someone in the future if they experience a similar issue. The code it's self is still as bullet proof as ever. Thanks.

Thanks Eerin, for your feedback, saves me time going over the code to find an error :smile:

7 Oct 2014, 9:19 AM
#489
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Some of my Option Values contain html code. This code is recognised and displayed correctly on the Product Info page but is not displayed correctly in the Dynamic sidebox - the complete code is shown instead of the formatted text.

I'm having difficulty in identifying the lines of Dynamic Filter code that control this - any suggestions?

7 Oct 2014, 11:46 AM
#490
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

simon1066:

Some of my Option Values contain html code. This code is recognised and displayed correctly on the Product Info page but is not displayed correctly in the Dynamic sidebox - the complete code is shown instead of the formatted text.

I'm having difficulty in identifying the lines of Dynamic Filter code that control this - any suggestions?

Never mind, found it, at last.

7 Oct 2014, 12:11 PM
#491
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Dynamic Filter [Support Thread]

simon1066:

Never mind, found it, at last.

Care to share?? Maybe it is something I cab incorporate in a new release?

7 Oct 2014, 1:27 PM
#492
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Yes, of course - didn't mention it as I thought wouldn't be of much interest

In tpl_dynamic_filter.php

change

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)) .' <span class="no_of_attributes">(' . htmlspecialchars(html_entity_decode($attributes->fields['quantity'], ENT_QUOTES)). ')</span>' . '</li>';

to

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 . '"' : '')) . html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES) .' <span class="no_of_attributes">(' . html_entity_decode($attributes->fields['quantity'], ENT_QUOTES). ')</span>' . '</li>';

I simply removed the two htmlspecialchars references. The same edit will be needed in the 'Link' and 'Dropdown' cases.

This allows html formatting of Option Values.

HOWEVER, this also raises a previous problem I had completely forgotten about, namely that the 'special' characters in html code such as < = " > / cause filtering errors i.e. 'There are no products to list in this category.', if I remove these characters then filtering with said Option Vale works as it should.

There was a post/edit made a while back regarding escaping special characters but I was never able to get it to work for these characters.

7 Oct 2014, 3:34 PM
#493
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Dynamic Filter [Support Thread]

simon1066:

Yes, of course - didn't mention it as I thought wouldn't be of much interest

In tpl_dynamic_filter.php
change

Thanks for that. I noticed this problem on a site I was working on a few weeks back, but I had other more important things to take care of at the time and never got back into looking for a solution.

I guess there is more interest than you expected eh? :-)

Thanks again

RodG

19 Oct 2014, 3:48 PM
#494
su35 avatar

su35

Zen Follower

Join Date:
Oct 2011
Posts:
168
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Hi Design75

Could you include the info about "How to update from old version" in the document?

9 Nov 2014, 5:58 AM
#495
su35 avatar

su35

Zen Follower

Join Date:
Oct 2011
Posts:
168
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

I have a problem with the price filter shown as the image below.
Attachment 14681
zen: v1.5.3; DF: got from here
I had thought it would be a issue from error merging. After copying the DF files to zen cart directly, there is nothing change, even if I set the Enable Price filter to No.
other thing: I have not set tax.
Is anybody can help?
Thanks

9 Nov 2014, 8:26 AM
#496
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Dynamic Filter [Support Thread]

su35:

I have a problem with the price filter shown as the image below.
Attachment 14681
zen: v1.5.3; DF: got from here
I had thought it would be a issue from error merging. After copying the DF files to zen cart directly, there is nothing change, even if I set the Enable Price filter to No.
other thing: I have not set tax.
Is anybody can help?
Thanks

It is a know bug i am working on right now. Better use the last version from the downloads section here

9 Nov 2014, 5:40 PM
#497
su35 avatar

su35

Zen Follower

Join Date:
Oct 2011
Posts:
168
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Thanks Design75
By the way, the 1.2bate is work on 1.5.1 version.

21 Nov 2014, 12:42 PM
#498
eyefultower avatar

eyefultower

New Zenner

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

Re: Dynamic Filter [Support Thread]

Hello,

I have the filter working on my site but have a problem.

It works great with existing attributes, but if I add an attribute and add it into 'include options' it shows up but returns no results when clicked on.

Any ideas? Thanks.

1 Dec 2014, 2:18 AM
#499
su35 avatar

su35

Zen Follower

Join Date:
Oct 2011
Posts:
168
Plugin Contributions:
0

Re: Dynamic Filter [Support Thread]

Is the filter can be enable on home page?

1 Dec 2014, 7:51 AM
#500
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Dynamic Filter [Support Thread]

su35:

Is the filter can be enable on home page?

No, sorry, but at this time it only works if you are viewing a category. I am am sure it can be done, but it will need some coding. If you like you can try :D, because I am lacking the time at the moment.