Search query encoding ampersand

thisconnectthisconnect Member Posts: 30 ✭

if i want to look up a product by name, i use this PHP to generate the API url string:


(i tried plain 'urlencode()' and double encoding 'urlencode(urlencode())' too)

when $search includes an ampersand &, no products are found.

i.e. search for 'B&W Speaker' does not give me a result, but 'W Speaker' does.

any ideas in how to encode a string with & in it properly?



  • gregaricangregarican Member Posts: 926 
    Can you try HTML escaping it as %26 to see if that works?
  • thisconnectthisconnect Member Posts: 30 ✭

    i'm still not finding the correct way if searching a product through the API...


    i want to find this: "Coco & Pine - badcape Colette Tetra" (exact copy of "description" field in Lightspeed Retail)

    so my search string looks like this:


    is is rawurlencoded and the description is pre- and appended by % (%25)

    nothing is found...

    even if i try searching for "badcape Colette Tetra" (part of description, without any special characters), i do not get results?

    but when i search for "Colette Tetra" (smaller part) i do get the product in the results!

    that looks very random to me...

    also have problems with single quotes in search:

    example: Baby's Only

    encoded to: Baby%27S%20Only -> no results (backslashing does not work either)

    anyone has more info?

Sign In or Register to comment.