Post by s101west » Wed Sep 11, 2019 3:02 am

I am having trouble when filtering products. I believe I have everything set up correctly, but when I check a box within the filter section and then click the refine search at the bottom, it refreshes the page but doesn't actually filter nor show me anything different and my search parameter is deselected.

I am on OpenCart v. 3.0.2.0
My website is: https://customframingdesigns.com/frames/

Also, not sure if this is part of the same problem or not, but I am also not able to perform a backup through >Mantainence>Backup & Restore. I get a 500 error

Newbie

Posts

Joined
Fri Sep 01, 2017 8:09 am

Post by rjcalifornia » Wed Sep 11, 2019 11:26 am

s101west wrote:
Wed Sep 11, 2019 3:02 am
I am having trouble when filtering products. I believe I have everything set up correctly, but when I check a box within the filter section and then click the refine search at the bottom, it refreshes the page but doesn't actually filter nor show me anything different and my search parameter is deselected.

I am on OpenCart v. 3.0.2.0
My website is: https://customframingdesigns.com/frames/

Also, not sure if this is part of the same problem or not, but I am also not able to perform a backup through >Mantainence>Backup & Restore. I get a 500 error
Are you using the default refine search module? My search is different than yours (stock OpenCart) and I can filter any product

Image
A2 Hosting features: Shared Turbo Boost, Managed Warp 1, Unmanaged Hyper 1, and Warp 2 Turbo


Active Member

Posts

Joined
Fri Sep 02, 2011 1:19 pm
Location - Worldwide

Post by letxobnav » Wed Sep 11, 2019 12:27 pm

That is because OC developers are terrible at SEO URL implementations.

in catalog/view/theme/default/template/extension/module/filter.twig you have

Code: Select all

[code]<script type="text/javascript"><!--
$('#button-filter').on('click', function() {
	filter = [];

	$('input[name^=\'filter\']:checked').each(function(element) {
		filter.push(this.value);
	});

	location = '{{ action }}&filter=' + filter.join(',');
});
//--></script> 
[/code]
which is fine with SEO url's disabled, crap if they are enabled as there is no "?" anymore so adding a "&" alone will not do.
just add https://customframingdesigns.com/frames/?filter=16,5 to you browser address bar and see that the filter actually works with the right address.

change it to:

Code: Select all

<script type="text/javascript"><!--
$('#button-filter').on('click', function() {
	var xurl = new URL("{{ action }}");
	filter = [];
	$('input[name^=\'filter\']:checked').each(function(element) {
		filter.push(this.value);
	});
	xurl.searchParams.append('filter', filter.join(','));
	location = xurl;
	return false;
});
//--></script> 

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by s101west » Thu Sep 12, 2019 6:11 am

Thank you for your response. I replaced the code, but perhaps I am still missing something. It still doesn't work. The extension "Fix Filter-Opencart 3.x" was added a while back. Could that be causing the problem? I tried disabling it, but it didn't help.

Newbie

Posts

Joined
Fri Sep 01, 2017 8:09 am

Post by letxobnav » Thu Sep 12, 2019 8:43 am

2 problems:

1) You did not make the change right or you did not clear your theme cache as this is still in your html

Code: Select all

  <div class="panel-footer text-right">
    <button type="button" id="button-filter" class="btn btn-primary">Refine Search</button>
  </div>
</div>
<script type="text/javascript"><!--
$('#button-filter').on('click', function() {
	filter = [];

	$('input[name^=\'filter\']:checked').each(function(element) {
		filter.push(this.value);
	});

	location = 'http://customframingdesigns.com/frames/&filter=' + filter.join(',');
});
//--></script> 

  </aside>
2) you are mixing http:// to https://

Code: Select all

	location = 'http://customframingdesigns.com/frames/&filter=' + filter.join(',');
which causes an http to https redirect which makes you lose the filters.

PS. that fix-filter thing just changes how the query handles the filter groups (and vs. or) so has no relation here.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by s101west » Fri Sep 13, 2019 1:40 am

I have cleared the theme cache and It looks like it is loading the correct change to the filter.twig. Am I changing the wrong file?

I am not a programmer, but is it odd that this script is commented out?
I can't seem to figure out why it would be switching back and forth between http and https... unless that is a setting I have misdirected someone within OpenCart. This entire site is covered by a purchased SSL certificate.

Attachments

Screen Shot 2019-09-10 at 11.12.28 AM.png

Screen Shot 2019-09-10 at 11.12.28 AM.png (75.84 KiB) Viewed 2468 times


Newbie

Posts

Joined
Fri Sep 01, 2017 8:09 am

Post by letxobnav » Fri Sep 13, 2019 7:14 am

first:
in config.php
make sure both servers are https

Code: Select all

// HTTP
define('HTTP_SERVER', 'https://YOUR_DOMAIN');

// HTTPS
define('HTTPS_SERVER', 'https://YOUR_DOMAIN');
That javascript is not commented out but it is also not the version I posted.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by s101west » Fri Sep 13, 2019 1:35 pm

Changing the https in the config file worked! The filter now seems to be working.

Thank you so much for your help!!

Newbie

Posts

Joined
Fri Sep 01, 2017 8:09 am
Who is online

Users browsing this forum: No registered users and 8 guests