Gonzalo
September 5, 2019, 1:31pm
1
Hi
Having problem with filtering products
When selecting brands the url keeps adding with additional brand to the url, as showed below:
litiumdemo.local/woman?brand=saint%20tropez&brand=adrian%20hammond&brand=odd%20molly
And if the brand has special character “&” (Count & Countess), the search doesn’t work, it just keeps adding the brand to the url:
litiumdemo.local/woman?%252520countess&%2520countess&brand=count%20&%20countess
Is it a bug?
Thanks in advanced.
Litium version: 7.2
This is a bug, please report this in the Docs.
NilsN
September 6, 2019, 7:16am
3
A workaround could be to change FacetedSearch.action.js and use encodeURIComponent on group.id and val in toFilterCriteria.
const toFilterCriteria = groups => groups
.map(group => group.selectedOptions
.filter(val => val && val.length > 0)
.map(val => `${encodeURIComponent(group.id)}=${encodeURIComponent(val)}`)
)
.reduce((flat, current) => [...flat, ...current], []);
Since you encode the group.id as well, you need to decode the param in the submit function, otherwise it won’t remove the filter when you click it.
The entire query string will be encoded again in History.middleware.js though.
Gonzalo
September 6, 2019, 1:48pm
4
Thanks Nils, this is a working workaround.
We are currently working on just adding brands to brand parameter.
litiumdemo.local/woman?brand=saint%20tropez&brand=adrian%20hammond&brand=odd%20molly
so instead for code above, it would request the code below:
litiumdemo.local/woman?brand=saint%20tropez,adrian%20hammond,odd%20molly
It will be hard to detect if the comma delimiter in the brand is a delimiter between the brands or if the brand name contains a comma delimiter. I don’t think it will be possible in a good way to reorganizing the values like that.
system
Closed
October 6, 2019, 10:00am
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.