EmicoEcommerce / Magento2Tweakwise

Magento 2 module for Tweakwise integration
Other
4 stars 16 forks source link

Hidden filters doesn't work with AJax #150

Open vshatylo opened 4 months ago

vshatylo commented 4 months ago

Issue Brief

Tweakwise allows setting the filter as "hidden|not to show" in the filter template but filtering by it is still workable. Such filters could be used for marketing to point users to special products.

Environment

PHP Version: 8.1 Magento Version: 2.4.6 Tweakwise Version: 5.7.3 Tweakwise Export Version: 5.4.0 Magento Deploy Mode: production

Pre-conditions

Steps to reproduce

  1. visit a category with an applied "hidden" filter. e.g. /category_path/?test_hidden=test
  2. try to navigate to the second page, or change sorting, or add one more filter

Actual result

Expected result

ah-net commented 4 months ago

@vshatylo The problem with this is that magento doesn't know which filters exists in TW and which filters are hidden filters.

Do you have an suggestion how to determine which filter should be applied and which not?

vshatylo commented 4 months ago

i was thinking about 2 ways

ah-net commented 4 months ago

@vshatylo

Solution 1 has the problem that you can't detect which filter you just deactivated if you use all url params. Than the deactivated filter just gets activated again.

Solution 2 could work. But filter templates can differ for categories. You can determine if an filter is an hidden filter, but it can be an hidden filter in an different filter template than the current category.

I'll discuss this internally and see if we can come up with an solution for this.

ah-net commented 3 months ago

@vshatylo Is there an reason that you don't use the ALP module for this? You can enable hidden filters there, and an ALP works on an specific url

vshatylo commented 3 months ago

@vshatylo Is there an reason that you don't use the ALP module for this? You can enable hidden filters there, and an ALP works on an specific url

Expected result the results should be the same: despite of whether it's rendered by AJax or not.

now it works differently

ah-net commented 3 months ago

@vshatylo Then the bug is (in my opinion) that you can set an hidden filter via the url (?hidden_filter=test).

So if you want to use an hidden filter, you can use an ALP page. And otherwise if the hidden filter is in the url. It should not change the product selection on the first page.

ah-net commented 3 months ago

To fix this issue you have two options

  • apply all filters that are in the URL when building Ajax requests. in this case, hidden param are not lost during Ajax filtering. Tweakwise anyway ignores filters that are not in the filter template.
  • sync filter templates with Magento. Tweakwise allows us to get information about filter templates by API. Then we could determine which filters are hidden.

But both options have problems

Solution 1 has the problem that you can't detect which filter you just deactivated if you use all url params. Than the deactivated filter just gets activated again.

Solution 2 could work. But filter templates can differ for categories. You can determine if an filter is an hidden filter, but it can be an hidden filter in an different filter template than the current category.

@jansentjeu Can I get your input on this? I don't think both solutions are good options to fix this problem.

ah-net commented 2 months ago

@vshatylo There are currently no plans to fix this. This is due to the low impact of this issue, and not having good solution for this problem. This problem only occurs if you know the values for an hidden filter, and add them to the url yourself.