We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37377
    • 64 Posts
    Hi all,

    I was was wondering if it's possible to modify the where statement to something like the following:

    "oem_nummer:LIKE" => "%$zoekwaarde2%",
    	"OR:REPLACE(oem_nummer,' ',''):LIKE" => "%$zoekwaarde2%"


    I need to be able to search the column oem_nummer with or without spaces. In the database all product codes (oem numbers) or seperated with spaces and people need to be able to find the right products when they enter the oem number without spaces as well.

    Thanks in advance

    Steffan
      • 33968
      • 863 Posts
      Hi Steffan

      If your oem numbers are of a consistent format why don't you pre-format the inputted query string to add or remove spaces as necessary before feeding it to the xpdo statement?

      I expect that would make for a much quicker search too.
        • 37377
        • 64 Posts
        The numbers aren't in a consistent format and it's a free query input so it searches in the product description as well...
          • 33968
          • 863 Posts
          In that case you could look into using xPDOCriteria: http://rtfm.modx.com/display/xPDO20/Retrieving+Objects
            • 37377
            • 64 Posts
            Thanks Lucas,

            I didn't know that I could write my own queries with xpdo.