No ajax filtering

  • Posts: 1119
  • Thank you received: 114
5 years 4 months ago #308969

Hi,

This is a bit odd but i still looking how can i do something after filter areas have been refreshed. Any guide is welcome.

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 4 months ago #308980

Hi,

Found another issue. Using IE11 the ajax refresh doesn't work. It is trying to refresh content and stuck with console error below:



Thanks

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
5 years 4 months ago #308985

Hello,

Please indicate your HikaShop version number AND your build number too.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 4 months ago #308995

Hi,

1. HikaShop Business 4.2.0 [1907171646]. Using IE11 the ajax refresh doesn't work. It is trying to refresh content and stuck with console error below:



2. I've been trying to retain some click class "open" ( which is added on click to show dropdown ) after filter refresh but not sure how properly this should be done with new ajax filters.

Basically the idea is to wrap each filter in dropdown and on click filter, the dropdown will be shown with checkboxes. I do have "submit on click" set so after checkbox is clicked, filters are refreshed and dropdown hidden due missing "open" class. So i am trying to add it back after filter is refreshed. As example i do have this:
window.Oby.registerAjax("filters.updated",function(params){ 
jQuery('.dropdown_size').addClass('open');
});

However this runs in same time filter is getting refreshed. How to check that filter refresh is done and only then do what i need?

Thanks

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 4 months ago #309023

Hi,

1. I've added a patch. It should work fine now.

2. I've added a patch for that too so that we trigger the filters.updated after all the areas have been updated on the page. It should work much better now.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 4 months ago #309028

Hi,

Those both patches works fine now. Thank you

However there is now another issue with HikaShop Business 4.2.0 [1907221606].
If i add any script tag for each filter, as example:

<div class="hikashop_filter_main hikashop_filter_main_<?php echo $filters[$count]->filter_namekey; ?>" style="<?php echo $height; ?> float:left; width:<?php echo $widthPercent*$filters[$count]->filter_options['column_width']?>%;" >
			<?php echo '<div class="hikashop_filter_'.$filters[$count]->filter_namekey.'">'.$html[$count].'</div>'; ?>
		</div>
			<script>
				jQuery('.hikashop_filter_main_<?php echo $filters[$count]->filter_namekey; ?>').addClass('open');
			  </script>

After ajax refresh, those scripts are removed. It was working fine with older Hikashop version.
As every filter have unique ID, i need assign unique function to this filters and this can't be done in some js file...

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 4 months ago #309036

kyratn wrote: After ajax refresh, those scripts are removed. It was working fine with older Hikashop version.


A bit update on this. It seems with older version those scripts were removed from html too but script it self was working fine. Only not visible in html at the place it should be.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 3 months ago #309030

Hi,

I'm not sure.
I didn't do any modification which would prevent javascript from being triggered.
However, I've had to add several more patchs today for this:
www.hikashop.com/forum/install-update/89...0-update.html#309029
So I would recommend to update again and see how it goes (make sure you redo your filter.php override as we had to make changes in it).

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 3 months ago #309051

Hi,

I have update and tried with protostar template, still no luck. "script" tags are removed from html.

So this is what i have now:

1. I use default filter.php with no modification and add this a bit of script:

<script>
jQuery('.hikashop_filter_main_<?php echo $filters[$count]->filter_namekey; ?>').addClass('open');
</script>

after this:
<div class="hikashop_filter_main hikashop_filter_main_<?php echo $filters[$count]->filter_namekey; ?>" style="<?php echo $height; ?> float:left; width:<?php echo $widthPercent*$filters[$count]->filter_options['column_width']?>%;" >
			<?php echo '<div class="hikashop_filter_'.$filters[$count]->filter_namekey.'">'.$html[$count].'</div>'; ?>
		</div>

The output of html before ajax filtering is done:



This is the output of html after ajax filtering is done:



If i use hikashop.js downloaded on "com_hikashop_business_v4.2.0_2019-07-18_12-18-08" The html is like this:



As you can see the "script" tags are also removed but jquert addclass function is still executed. All filter have class open...


2. I found that it doesn't matter which hikashop.js file i use the on above or fresh installed, each time after ajax refresh console throws error:



Maybe it is related to "script" issue?

For both cases i hope you can reproduce these issues and fix them.

Thanks

Attachments:
Last edit: 5 years 3 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 3 months ago #309057

Hi,

I've added some modifications to the filter refresh system:
www.hikashop.com/forum/install-update/89...0-update.html#309056
The javascript coming back from the server was indeed not run anymore due to another patch I had to do for the support of IE which produced a side-effect I didn't expect.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 3 months ago #309076

Hi,

Thank you. It seems everything is working great now.

However i would like to know what is happening with script tag and it's content after ajax refresh. Script is executed but not visible in html, the place it should be. Trying to inspect with dev tools "event" i see that it comes from hikashop.js file now?

Regards

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 3 months ago #309084

Update.

I was a bit hurry saying that everything works fine. Now it does refresh 2 times. Inspecting with dev tools, you clearly can see that hikashop_checkout_loading is added, removed, added, removed. As usual tried with protostart template.

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 3 months ago #309100

Hi,

I don't see the problem on my end. I have the same number of requests than before with the changes:
- 1 POST request to send the filter data to the server
- 1 GET request for each area to refresh on the page

And regarding the javascript, that's normal. adding script tags to the HTML of the DOM won't run it. So the refresh system extract the javascript code from the HTML returned and execute it just after adding the rest of the HTML

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 3 months ago #309105

Hi,

Thanks for explanation regarding javascript.

So it seems that the price cursor is giving issues. If i unpublish it then everything works fine.

Here are the settings of it.




Hope you can reproduce it.


Thank you

Attachments:
Last edit: 5 years 3 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 3 months ago #309116

Hi,

Ah yes, I was able to reproduce it with the cursor filter. It comes from previous modifications we had to do when implementing the input fields. I've added a patch for that on our end.
So I would recommend to update again.

The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 3 months ago #309137

Hi,

Seems everything works perfect now.

Thank you for your great support and keep up the good work!

Cheers

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

  • Posts: 200
  • Thank you received: 75
5 years 3 months ago #309864

Hi,

perhaps we can continue this thread as it fits the title, the new ajax filters work without problems, but we've found they do have several drawbacks:

- with the "old" way of filtering, users could view a product then go back to the product listing and all their filter settings would still be exactly the same, and they could simply continue browsing where they left off. Now with ajax filters, they have to redo all their filters every time they return to the product listing, which is a big downside compared to how it was before and we're afraid will quickly become very annoying to users.

- most of our listings have several hundred products and with ajax filters it usually takes several seconds when applying a filter before the new set of products is shown, which is quite long. After running some comparison tests, we've found in many cases the old filters which reloaded the entire page were actually faster.

- with the old way of filtering it allowed users to save/favourite/share pages with their filter settings in the url, which is no longer possible now.
- also the old filters allowed behind-the-scenes analytics to see what filter options were looked at the most or the least, quite valuable information in our view, which is no longer possible now.

This is just our experience so far, but due to the above issues, we're inclined to go back to the old way of filtering.
We didn't see any setting in the back-end to choose whether you want to use ajax filters or not, though if we're not mistaken we can still switch ajax off by adding in the config table ajax_filters and setting it to 0, correct? Will this continue to work/be supported even in future?

Thanks.

The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 3 months ago #309867

Hi,

I just would like to add that I think the filter params should be added to the url as soon as you filter something, this would fix most of what GW wrote. We can take a look how big shops handle it. As example asos.com

Also, seems "redirect post mode" settings have no impact now on filters....

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
5 years 3 months ago #309868

@GW,

Regarding filter settings. I just found that if you disable redirect post mode then filters wont reset :)

Shouldn't it work other side tho?

The following user(s) said Thank You: GW

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 3 months ago #309892

Hi,

1. Turning off the redirect POST mode should allow you to get the filters back when you return to the listing page.

2. The speed improvement or not will depend on several factors. It can be faster while it can be slower. Applying filters and loading products can be fast (if you don't have a lot of products / filters) or slow, and similarily, the display of the rest of the page (other modules, template, etc) can be fast or slow (if you have heavy duty modules, a template with a lot of bells and whistles, etc). So if the display of the filters/products is fast and the other modules / template is slow, having AJAX filters will be faster. If you have a lot of products/filters and fast modules/template display, then AJAX filters will be slower as there a a bit more back'n'forth between the browser and the server.

3. Adding the parameters to the URL to be able to favorite/share the pages might be possible to add back in the future. I actually did some tests to allow for that (with the modification of the browser history/URL) but I wasn't able to get good results. It created other problems so I rolled back on that. But maybe we could look into it again in the future.

4. The ajax_filters hidden setting in the database is a good way to go back to the old system system. We plan on supporting it in the future yes.

Please Log in or Create an account to join the conversation.

Time to create page: 0.134 seconds
Powered by Kunena Forum