Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering option values that contain an ampersand & are not urlencoded #216

Closed
mdevrees opened this issue Aug 29, 2024 · 3 comments
Closed

Comments

@mdevrees
Copy link

mdevrees commented Aug 29, 2024

Issue Brief

Filtering with option values that contain an ampersand & are not urlencoded

Environment

  • PHP Version: 8.2
  • Magento Version: 2.4.6-p7
  • Tweakwise Version: 6.0.1 (also tested on 8.0.0)
  • Tweakwise Export Version: 7.0.1
  • Magento Deploy Mode: producten
  • Third party modules:

Steps to reproduce

  1. Create filterable attribute in magento and give it value A & B, link it to a product and export it to Tweakwise
  2. Assign product to category, enable TW layered navigation
  3. Navigate to category, try to filter via layered navigation

Actual result

  1. On applying the filter, the url is not encoded (https://example.com/clothing?brand[0]=A & B) whereas when I change the ampersand to %26 it works perfectly fine.
  2. There are no products shown as a result

Expected result

Url encoded and products shown

Possible fix

diff --git a/Model/Catalog/Layer/Url/Strategy/QueryParameterStrategy.php b/Model/Catalog/Layer/Url/Strategy/QueryP
arameterStrategy.php
index e5c3a713..63014ea2 100644
--- a/Model/Catalog/Layer/Url/Strategy/QueryParameterStrategy.php
+++ b/Model/Catalog/Layer/Url/Strategy/QueryParameterStrategy.php
@@ -321,7 +321,7 @@ class QueryParameterStrategy implements UrlInterface, FilterApplierInterface, Ca
         $attribute = $item->getAttribute();

         $urlKey = $settings->getUrlKey();
-        $value = $attribute->getTitle();
+        $value = urlencode($attribute->getTitle());

         $values = $this->getRequestValues($request, $item);

This is not a complete fix however. When selecting other attribute values and removing the A+B one, there are still some strange things going on.

@ah-net
Copy link
Collaborator

ah-net commented Aug 29, 2024

@mdevrees This only seems to happen if ajax filtering is turned off. Can you confirm that you have ajax filtering turned of in the magento tweakwise settings?

@mdevrees
Copy link
Author

mdevrees commented Aug 29, 2024

Hi @ah-net
I can confirm ajax filtering is turned off in the tweakwise settings.

@ah-net
Copy link
Collaborator

ah-net commented Dec 5, 2024

Hi @mdevrees,

The fix will be included in the next release (though we're not sure of the exact timing yet). However, I suspect the current solution might cause issues when the URL strategy is set to "path." This means the issue will need further testing, and the fix may be adjusted if necessary.

Thanks for your patience! Let me know if you have any questions in the meantime. 😊

@ah-net ah-net closed this as completed Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants